tags:

views:

88

answers:

4
<div id="target">
<div id="exclude"></div>
<div></div>
...
</div>

$('#target').children().hide(); will hide all.

+5  A: 

You can use :not(#exclude) to hide all others.

$("#target div:not(#exclude)").hide();

or via $.filter():

$("#target").children().filter(":not(#exclude)").hide();
Jonathan Sampson
A: 

Use the :not selector

rahul
A: 

Have you tried using the "not" selector with the id that you want to exclude?

http://docs.jquery.com/Selectors/not#selector

Also, the obvious answer would be to follow it with a $('#exclude').show()

nategood
+1  A: 

I believe that $('#target > div').not('#exclude').hide() should do what you want.

Or alternately if you want sub-children that are divs too, $('#target div').not('#exclude').hide()

Crast