Given:
<div>
<span><a href="#">abc</a></span>
<span><a href="#">def</a></span>
</div>
Is there a way to do 开发者_Python百科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.
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/
加载中,请稍侯......
精彩评论