?
Solved

what this meaning of '>' in jquery

Posted on 2013-02-05
5
Medium Priority
?
250 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 1336 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 664 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 1336 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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 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…
Suggested Courses

765 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