如何使用RegEx和Jquery隐藏DIV元素
问题描述:
我想在下面隐藏除class="imagebrowser"
之外的所有其他元素,
I would like to hide all other element except class="imagebrowser"
in following,
<div class="entry">
<p>Heading 1</p>
<p>Heading 2</p>
...
<p>Heading n</p>
<b>This is abold text</b>
<div>This is a div element</div>
<div class="imagebrowser">
Hello world
</div>
</div>
预期结果,
<div class="entry">
<div class="imagebrowser">
Hello world
</div>
</div>
请帮助
答
$('div.entry div').not('.imagebrowser').hide();
这将隐藏除"imagebrowser"类之外的所有"div"中的div.
This will hide all divs inside the "entry" div other than those with the class "imagebrowser".