I have an element #xxx
and I have to select all children (any level) and all parent of this element. I dont want to select the element itself.
So far I've been using this jquery code but I am pretty sure there must be a way to make this more efficiently (maybe using addBack):
$("#xxx").find("*").add($("#xxx").parents())
Do you suggest any other alternative that does not make use of add()
cause I think this selector is not efficient cause it queries internally again the #xxx. I think using addBack()
would be nicer cause it does not cause another search for the element #xxx.