Reputation: 15455
Given:
<div>
<span><a href="#">abc</a></span>
<span><a href="#">def</a></span>
</div>
Is there a way to do a string comparison with toUpperCase() between a given string value and the link text (as shown above in the span collection) and if it doesn't match hide the span? Anyway to incorporate "contains" in the mix?
Thanks,
rod.
Upvotes: 0
Views: 74
Reputation: 72991
You could do the following. But keep in mind this will run for all a
tags within a span
. You should modify it will a id
on your div
or some kind of class
attribute.
$('span a').each(function() {
var anchor = $(this);
if (anchor.text().toUpperCase() == 'ABC') {
anchor.hide();
}
});
See it in action: http://jsfiddle.net/KCCVm/
Upvotes: 1