Mahmoud Farahat
Mahmoud Farahat

Reputation: 5475

What does the jquery selector '$("#someID > * *")' mean?

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?

Upvotes: 7

Views: 1037

Answers (2)

Sarfraz
Sarfraz

Reputation: 382756

$('#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.

Upvotes: 2

SLaks
SLaks

Reputation: 887489

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 > *').

Upvotes: 9

Related Questions