$('a:contains(foo)').hide();
Done.
Or:
var customValue = "foo"
$('a').filter(function(){
return this.innerHTML === customValue;
}).fadeOut();
With the later option you custom it a lot more, like:
var customValue = "foo"
$('a').filter(function(){
return this.innerHTML === customValue &&
$(this).closest('div').length;
}).fadeOut();
One approach, assuming the text you're searching for is exactly the string you use, shamelessly stealing from paying homage to Jonathan Sampson:
Creating the :exactly
selector:
$.extend($.expr[":"], {
exactly: function( element, index, details, collection ){
return $(element).text() === details[3];
}
});
Used like so:
$('a:exactly("foo")').fadeOut();
References:
:exactly()
selector: http://sampsonblog.com/279/creating-your-own-custom-jquery-filters:exactly()
: Is there any selector to do a perfect match against text?