How to hide all children div except a specific one with jQuery?

jquery

Solution

What you're wanting to do is hide all of the siblings of a particular element. That's relatively simple with jQuery using the `.siblings` method:

​$("#exclude").siblings().hide();​​​​

This will hide all elements on the same level, in the same parent element.

Problem

``` <div id="target"> <div id="exclude"></div> <div></div> ... </div> ``` `$('#target').children().hide();` will hide all.

Original source