1

With the risk of being redirected to a dublicate question, what is the difference between using $("ul li") and $("ul").find("li")?

Stig Perez
  • 3,595
  • 4
  • 23
  • 36

2 Answers2

1

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.

Community
  • 1
  • 1
Justin Helgerson
  • 24,900
  • 17
  • 97
  • 124
0

$("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.

Jashwant
  • 28,410
  • 16
  • 70
  • 105