[英]hide div that contains <p> that contains “text” - how to
<div id="example">
<ul>
<p>text</p>
</ul>
<div>
i need to hide div itself 我需要隐藏div本身
The solutions with parent()
can't guarantee that the right parent is being used. parent()
的解决方案无法保证正在使用正确的父级。
Use this: 用这个:
$('div').has("p:contains('text')").hide();
$("div p:contains('text')").closest("div").hide();
工作解决方案: http : //jsfiddle.net/7qmwj/8/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.