Solved

what this meaning of '>' in jquery

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

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 42

Expert Comment

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
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 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)

762 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

24 Experts available now in Live!

Get 1:1 Help Now