Reputation: 2352
In this jQuery Method chain
$(SELECTOR1).find(SELECTOR2).doSomethingThatReturnsjQueryObject()
I would like to continue the chain with the return value of $(SELECTOR1)
, so the outer DOM node itself.
I am looking for the best solution in performance.
$(SELECTOR1)
in a variable for further use? .parents()
/ .closest()
? Is there a gentle method, or an array-like-object trick to get the last method's return value?
Upvotes: 1
Views: 208
Reputation: 67207
In order to tackle this kind of situations .end()
was made.
$(SELECTOR1).find(SELECTOR2).end().doSomethingThatReturnsjQueryObject()
Upvotes: 1