开发者

How to hide all children of a container except a specific one using jQuery?

开发者 https://www.devze.com 2023-01-01 09:23 出处:网络
<div id=\"container开发者_Python百科\"> <div id=\"specific_one\">..</div> ... </div>
<div id="container开发者_Python百科">
<div id="specific_one">..</div>
...
</div>

I want to hide all children of #container except #specific_one, how to do that?


have you tried something like:

$('#container *:not(#specific_one)').hide();

or

$('#container').children(':not(#specific_one)').hide();

and I think this one is faster...

$('#container #specific_one').siblings().hide(); //please comment on this guys...


$('#container').children().not('#specific_one').hide();
0

精彩评论

暂无评论...
验证码 换一张
取 消