What does ">" mean in jQuery and how to use it? -


i'm new jquery code, , saw code this:

var $pages = $('#main > div'); 

does mean $pages first div under #main or divs under #main? if have html code:

<div id="main">     <div class="sub-div" id="1">1</div>         <div id="1a">1a</div>     <div class="sub-div" id="2">2</div>     <div class="sub-div" id="3">3</div> </div> 

so, $pages array contain 3 divs or first one?

additionally, can use

var $pages = $('#main > div > div'); 

to "1a" ?

many thanks!

$pages immediate child divs of #main. if have

<div id=main>     <div id=1>         <div id=2></div>     </div>     <div id=3></div>     <div id=4></div>     <span id=5>         <div id=6></div>     </span> </div> 

then $('#main > div') fetch 1, 3, , 4.

if did $('#main div') you're finding matching descendants, not immediate ones, match 1, 2, 3, 4, , 6.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -