Haradzieniec
Haradzieniec

Reputation: 9338

jQuery: are these all statements true for find() method?

I'm curious if all the statements below are equivalent:

$(".postcell div").find(".post-taglist")
$(".postcell").find("div").find(".post-taglist")
$(".postcell").find("div .post-taglist")

and if it is valid for any number of .find in chain, any classess, ids etc.

The reason I ask is to be sure I don't miss anything when I replace selector with (variable + the rest part of the selector).

Upvotes: 0

Views: 27

Answers (1)

Blake Frederick
Blake Frederick

Reputation: 1670

Yes all of those statements should return the same thing.

$(".postcell").find("div").find(".post-taglist") will be slightly slower than the other two.

Upvotes: 1

Related Questions