views:

77

answers:

2

What is the meaning of this selector: $("#someID > * *")

I know that > means child nodes and * means all nodes, but I'm confused by the two asterisks. Any ideas?

+8  A: 

It selects all grandchildren or lower of #someID.

Explanation:

#someID > * selects all direct children of #someID.
Adding  * will select all descendants of those children. (but not the children themselves)

Thus, it will select all descendants of #someID except for its direct children.

It could also be written as $('#someID *').not('#someID > *').

SLaks
Proof: http://jsfiddle.net/wh9W9/1/
Harmen
Could also be written as: `$('#someID').children().find('*');`
patrick dw
@Patrick: You're right; that's much clearer, and probably a little faster.
SLaks
+2  A: 
$('#someID > * *')

Get all/any elements which are direct/immediate children of #someID and then get any descendants inside those elements there by only getting descendants.

Sarfraz
Nope. It won't select its direct children.
Harmen
@Harmen: I did not say either, it will select descendants ultimately :)
Sarfraz
@Sarfraz, you used the word `get` two times with another meaning, I guess...
Harmen
@Harmen: Yes that could have caused the confusion, added few more words at the end. Thanks :)
Sarfraz