Reputation:
I am learning the ways to get a collection together. Is there a way to make the following selection simpler? It's not a real world example, I'm just trying to understand. I' have this ul
and want to get the first li
with all its following content.
<ul class="foo">
<li>
<div><p></p><div>
<div><a></a><div>
</li>
<li>
<div>content<div>
<div>content<div>
</li>
</ul>
I tried this, but then I am missing the children of the divs.
$('.foo li:first').children().addBack()
What's the easiest and most performant way to get all of them? Thanks
Upvotes: 0
Views: 36
Reputation: 3735
You will have to use "*"
selector for this
$('.foo li:first').find("*")
But remember it the slowest selector, hence always try to avoid using it
For more details check it out
Upvotes: 1