Reputation: 806
How do I select all the divs within one parent-div except one? Let's say I have code like this:
<div id="parent">
<div id="child1"></div>
<div id="child2"></div>
<div id="child3"></div>
</div>
And I want to select #child1
#child2
. Of course I could just select them normally, but let's say I have many child-divs.
P.S. I don't want any selector like last or something since it's not said it has to be always the last that I want to skip.
Upvotes: 0
Views: 1072
Reputation: 4218
you can use not
method.
$("#parent > div").not("#child3")
this will select all direct children of parent div except child3
Upvotes: 2
Reputation: 57105
$('#parent > div').not('#child3');
or
$('#parent > div:lt(2)').
or
$('#parent > div:not("#child3")');
Upvotes: 2
Reputation: 115045
You can use the :not
pseudo-class in CSS...no need for Jquery
#parent div:not(#child3) {
/* your styles here */
}
Upvotes: 1