Solved

what this meaning of '>' in jquery

Posted on 2013-02-05
5
239 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now