Reputation: 3813
With the risk of being redirected to a dublicate question, what is the difference between using $("ul li") and $("ul").find("li")?
Upvotes: 1
Views: 46
Reputation: 29005
$("ul").find("li")
is faster than $("ul li")
.
$("ul li")
is going to be changed into $("ul").find("li")
after some checks and breaking.
find() appeared faster than children() to me in single level selections.
Upvotes: 0
Reputation: 25521
You may find this similar question of interest: What is the fastest method for selecting descendant elements in jQuery?
If you only need first level children, using .children()
will give you a performance boost since there is less to interrogate.
Upvotes: 1