Thursday, October 4, 2012

jQuery hierarchy selector


The jQuery hierarchy selectors are used to select elements from a page based on their position and relationship with their parent elements. For example the [input[type=text]:first]  selector will select the first textbox element in the page

In this post we shall see the various hierarchy selectors available in jQuery, and how to use them to filter out elements.

The following are the hierarchy selectors available in jQuery.

Selector
Element selected
:first
First element in the page
:last
Last element in the page
:even
All event elements in the page
:odd
All odd elements in the page
:only-child
Elements which are the only child for their immediate parent
.parent
Parent of the element
:nth-child(x)
Child element in the position x
:empty
Elements which do not have child elements
input[type=text]:first
First TextBox in the page
input[type=text]:last
Last TextBox in the page
select:first
First Drop Down in the page
select:last
Last Drop Down in the page

Search Flipkart Products:
Flipkart.com

No comments: