Reputation: 2563
<div id="example">
<ul>
<p>text</p>
</ul>
<div>
i need to hide div itself
Upvotes: 2
Views: 3416
Reputation: 9382
$("div p:contains('text')").closest("div").hide();
Working solution: http://jsfiddle.net/7qmwj/8/
Upvotes: 0
Reputation: 385284
The solutions with parent()
can't guarantee that the right parent is being used.
Use this:
$('div').has("p:contains('text')").hide();
Upvotes: 1