Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using > in jquery selector [duplicate]

Possible Duplicate:
What does a > b mean?

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.

like image 514
Chin Avatar asked Jul 26 '12 12:07

Chin


2 Answers

Just refer to http://api.jquery.com/child-selector/ to clear you doubt about >

like image 31
vivek salve Avatar answered Sep 22 '22 13:09

vivek salve


Basically the > indicates, that only direct children are matched. If the > is omitted, then ever child of every level below is matched.

If you have a structure like this:

<div id="A">
  <div id="B">
    <div id="C"></div>
  </div>
</div>

a selector like:

#A > #B

Should return you B, but

#A > #C

would not match with C whereas

#A #C

would.

like image 145
Slomo Avatar answered Sep 21 '22 13:09

Slomo