Reputation: 10912
I have a list like so:
<ul id="topElement">
<li></li>
<li>
<ul>
<li>
<ul>
<li>
</li>
</ul>
</li>
</ul>
<li>
Using jQuery, what is the best aka most efficient way to reference the first occurrence of a ul from #topElement.
That is to say, I do not want this...
$("#topElement ul")
Which will return every ul element in the tree. I only want the first ul down.
Thanks,
Upvotes: 2
Views: 1877
Reputation: 413757
I think that if you want the first "ul" you find inside the contents of the "ul" called "topElement", then you'd want this:
$('ul#topElement ul:first')
Upvotes: 4