I'm sure this is a complete bonehead move on my side, but can't figure out what's happening here.
I'm trying to select a div with a specific word in it, but Jquery seems to select the div on the wrong level. If you run this you'll see what I mean:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function () {
$(".ms-my-profileDetails:contains('Birthday')").css("color", "red");
});
</script>
</head>
<body>
<div class="ms-my-profileDetails">
<div>
Department : <a href='http://Someurl'>IT</a>
</div>
<br />
<div>
Birthday : <a href='http://Someurl'>1921-04-13</a>
</div>
<br />
</div>
</body>
</html>
The result of the above contains matches the entire div of Birthday and Department <div class="ms-my-profileDetails"> when I only want the Birthday Div.
Pls help. Tx
You should to something like:
$(".ms-my-profileDetails").children(":contains('Birthday')").css("color", "red");
That should look only on child divs and therefore select the div you want in this case...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With