I guess you want to select other divs that are siblings of #menu
and are child of #center
:
$("#center> *").not("#menu");
For all contents:
$("#center *").not("#menu");
Question
I'm trying to exclude one block from my jquery selection.
I have the following html structure:
<div id="center">
...
<div id="menu>
<!-- menu -->
</div>
...
</div>
Now I want to select all elements from #center except for the menu. That's why my jquery look like this:
$("#center").not("#menu")....
But this seems to select exactly the same as
$("#center")....
I also tried
$("#center:not(#menu)")....
And this also gave me the same result. So how can I select all elements from a div without a certain div?
Solution
I guess you want to select other divs that are siblings of #menu
and are child of #center
:
$("#center> *").not("#menu");
For all contents:
$("#center *").not("#menu");
OTHER TIPS
seems like you should be doing something like
$("#center").children().not("#menu");
Selects all with id='center' which doesn't have id='menu'
$("#center").not("#menu")
logically doesn't make much sense.
You should use
$("#center *").not("#menu");
instead which selects all elements inside center which don't have id=menu.