To select the sibling ‘ol’ elements, after the first ‘ol’ element; which doesn’t contain a ‘li’ element that itself contains an ‘ul’ element
The HTML source
<ol id="orderedlist">
<li>First element</li>
<li>Second element</li>
<li>Third element</li>
</ol>
<ol id="orderedlist2">
<li>First element, second list</li>
<li>Second element, second list</li>
<li>Third element, second list</li>
<li>Li with child ul
<ul>
<li>Child One</li>
<li>child two</li>
</ul>
</li>
</ol>
<ol id="orderedlist2">
<li>First element, third list</li>
<li>Second element, third list</li>
<li>Third element, third list</li>
<li>Li with child ul
<ul>
<li>Child One</li>
<li>child two</li>
</ul>
</li>
</ol>
jQuery to select & add css
/* Selects the sibling 'ol' elements after the :first 'ol' element which doesn't contain a 'li' element that itself contains an 'ul' element */
$('ol:first~ol > li').not(':has(ul)').css({
'border': '1px solid black',
'background-color': 'pink'
});
Please review the above code & advice some improvements using jQuery
[FONT=century gothic][SIZE=4]P.S.: I’m a n00b to jQuery. So please explain your code.
Thanx.[/SIZE][/FONT]