I am trying to show the first child of an element which does not have a class of "submitted"
So something like
$('#menu li:first-child:not(".submitted")').show();
HTML:
<ul id="menu">
<li class="submitted">stuff here</li>
<li class="submitted">stuff here</li>
<li>stuff here</li> <!-- This one needs to be shown -->
<li>stuff here</li>
<li>stuff here</li>
</ul>
Any ideas??
By using the :not(:first-child) selector, you remove that problem. You can use this selector on every HTML element.
The :not CSS pseudo-class can be used to select elements that do not contain a specific class, id, attribute etc.
The :first-of-type selector in CSS allows you to target the first occurence of an element within its container. It is defined in the CSS Selectors Level 3 spec as a “structural pseudo-class”, meaning it is used to style content based on its relationship with parent and sibling content.
$('#menu li:not(.submitted):first')
Try this:
$('#menu li:not(".submitted"):first').show();
http://jsfiddle.net/WDx3M/
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