$('something').parents('selectors')
lets me move several levels up the DOM at once, versus parent()
which unsurprisingly returns the current element's immediate parent. Unfortunately (though logically), children()
does not operate like parents()
and instead only returns the element's immediate children, similar to how parent()
works. I'm sure that I could whip up something that would get all appropriate descendants no matter how deep, but I'm wondering if there already is some relatively simple way to do this. Any chance?
views:
41answers:
4
+1
A:
$('something *');
… or if you already have a jQuery object:
$('*', foo);
David Dorward
2010-09-25 17:11:09
And `$("*", foo);` is synonymous with `$(foo).find("*");`
Peter Ajtai
2010-09-25 17:36:37
+1
A:
Cant you just use descendants?
I think your after something like
$('#something').childrens('.selectors');
Can you not jsut do:
$('#something *');
Or have i totally missed the point of your question?
RobertPitt
2010-09-25 17:12:46