Possible Duplicate:
What doesa > bmean?
Hi could any one tel me what this style of selector is used for?
$("> div", "#main-content")
is it the same as
$("div", "#main-content")
?
Not seen this style before and just stumbled on it in a template I just bought.
There are some great answers above. To specifically answer your question:
How the jQuery structure works:
$("tagToSelect", "context")which can also be expressed as
$("context tagToSelect")The “>” selects only tags immediately inside the context (one level deep)
So
$("> div", "#main-content")is technically the same as
$("#main-content > div")and will select all divs that are one level into #main-content (but no deeper)
Your other example:
$("div", "#main-content")is technically the same as
$("#main-content div")and will iterate through the entire DOM structure inside #main-content and find all divs
Hope this helps 🙂