Solved

what this meaning of '>' in jquery

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tiny glitch in my main slider 3 48
Worldmap 1 28
JQuery on multiple lines 3 16
Open grouped links on a page in new tabs via jquery 5 46
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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…

733 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