adding a *>* prior to a selector will cause selector to be a child
only and exclude further descendant levels
$('.start-here > li:has(li)')/// this will only look at first level
of li within class=start-here
Paul Mills wrote:
Try,
$('.start-here li:has(li)').append('<span class="ui-icon ui-
icon-plus"></span>');
Paul
On Aug 5, 4:59 pm, Panman <[email protected]> wrote:
I have selected a list that contains sub-lists. Now, I'd like to
search for the list items that contain sub-lists (but not including
the sub-list-items). I think the example below will explain what I'm
trying to do.
HTML:
<ul class="start-here">
<li>Do Not Need</li>
<li>NEED THIS ITEM
<ul>
<li>Do Not Need</li>
<li>Do Not Need</li>
</ul>
</li>
<li>Do Not Need</li>
<li>NEED THIS ITEM
<ul>
<li>Do Not Need</li>
<li>Do Not Need</li>
<li>NEED THIS ITEM
<ul>
<li>Do Not Need</li>
<li>Do Not Need</li>
</ul>
</li>
<li>Do Not Need</li>
</ul>
</li>
<li>Do Not Need</li>
</ul>
jQuery:
$('.start-here li').filter(':has(li)').append('<span class="ui-icon ui-
icon-plus"></span>');
The above jQuery statement selects the correct <li> but also all child
<li>'s, which I do not want.
|