Difference between $ (parent child) and $ (parent) .find (child) (in jQuery)

Possible duplicate:
jQuery single selector vs .find ()

Is there a difference between $ (parent) and $ (parent) .find (Child) in jQuery?

You may have several children:

$("div").find("span") , which will return all child spans. But isn't that the same with $("div span") ?

0
jquery
Aug 29 2018-12-12T00:
source share
1 answer

One very important difference is that $ overloaded with multiple values ​​and, as a result, is vulnerable to use with user-defined strings, but find is not.

E. g.

 $('.items .'+location.hash.substr(1)) // very bad idea $('.items').find('.'+location.hash.substr(1)) // this is OK 
+5
Aug 29 2018-12-12T00:
source share
β€” -



All Articles