I would like to know how could I write a jQuery selector that get all children from a parent element except first and last child?
Example of my current HTML:
<div id="parent">
<div>first child( i don't want to get)</div>
<div>another child</div>
<div>another child</div>
<div>another child</div>
(...)
<div>another child</div>
<div>another child</div>
<div>last child (i dont want to get neither)</div>
</div>
Like this:
$('#parent > div:not(:first, :last)');
You can do this:
$('#parent div').not(':first').not(':last')
Or
$('#parent').children().not(':first').not(':last')
Here not method will filter out first and last elements from the selector.
More Information:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With