Hide the parent DIV when an Anchor Text contains a certain Keyword
In the anchor text of the second link of the code below, the text "KEYWORD" can be found.
What I would l开发者_开发技巧ike to do is to HIDE the entire very first DIV (the one containing al the other code) whenever "KEYWORD" can be found in the anchor text of the link.
(I don't have control over the HTML - the code is coming from a different website)
<div>
<div>1. </div>
<div><a href="#nogo">buy now</a></div>
<div>More</div>
<div><a href="#nogo">bla bla KEYWORD bla bla</a></div>
<div> </div>
</div>
Can anyone tell me how to do this. In javascript or jquery I guess.
Update
I removed the href link and changed it to "nogo" for privacy reasons.
The href is a real link that changes all the time
Sorry I should have mentioned that.
$("div div a:contains('KEYWORD')").hide();
i guess u can do something like:
var hrefs = $('a[href^="nogo"]');
hrefs.each(function(){
if($(this).text().search(/KEYWORD/) != -1) $(this).parent().hide();
});
by the way: jquery is javascript ;-)
精彩评论