Solved

what this meaning of '>' in jquery

Posted on 2013-02-05
5
247 Views
Last Modified: 2013-02-11
What's the meaning of below.
 document.querySelector('#indicator > li.active')

and this
 document.querySelector('#indicator > li:nth-child(' + (this.currPageX+1) + ')')

thanks in advance
0
Comment
Question by:gamjaradio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 42

Assisted Solution

by:sedgwick
sedgwick earned 334 total points
ID: 38858318
> means inner

document.querySelector('#indicator > li.active')

look for html element with id = 'indicator' and look for inner element li who has class = 'active'

document.querySelector('#indicator > li:nth-child(' + (this.currPageX+1) + ')')

look for html element with id = 'indicator' and look for inner element li who's position is this.currPageX+1.
bare in mind that nth-child uses 1 based counting and not 0, so li:nth-child(2) yields 2nd li element and not 3rd.

check here:nth-child-selector
0
 
LVL 10

Expert Comment

by:Umar Topia
ID: 38858346
agree with sedgwick
0
 
LVL 43

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 166 total points
ID: 38859090
> means inner
No it doesn't

> is for a direct child only!

<ul id="indicator">
<li class="active">This is a direct child so will be selected</li>
<li>
     <ul>
     <li class="active">This won't get selected because it's a descendant, not a direct child!</li>
     </ul>
</li>
</ul>

Open in new window

#indicator > li:nth-child(2) will select the 2nd direct-child LI in #indicator

<ul id="indicator">
<li>Item 1</li>
<li>Item 2</li> //this will get selected
<li>Item 3</li>
<ul>

<div id="indicator">
<ul>
   <li>Item 1</li>
   <li>Item 2</li> //this won't get selected - it's not a direct child of #indicator
   <li>Item 3</li>
</ul>
</div>

Open in new window

0
 
LVL 42

Accepted Solution

by:
sedgwick earned 334 total points
ID: 38859119
@ChrisStanyon
you right, it is first level inner element.
sorry for the confusion.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 38875542
Weird way of assigning points, but hey!
0

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question