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,323
  • 4
  • 21
  • 32

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
  • 23,852
  • 17
  • 92
  • 123
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
  • 27,289
  • 16
  • 69
  • 100