Exploring jQuery Selectors
page 4 of 11
by Nihar Ranjan Nayak
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 41495/ 42

Basic Filters

:first

This will find the first selected element. The following code finds the first row in a table of 5 rows.

                   $("tr:first")

:last

Matches the last selected element.

:not(selector)

Filters out all elements matching the given selector. This will select all the elements which doesn't match the given selector. Consider the following example :

                   $("input:not(:checked))

This code will match all the check boxes which are not checked.

:even

Finds all the even elements. The following example find all the even rows i.e. 0Th, 2nd, 4th, 6th and so on.

                   $("tr:even")

:odd

Matches all the odd elements

                        $("tr:odd")

:eq(index)

Finds a single element by its index. The following example finds the 3rd TD in a set of Tds.

                   $("td:eq(3)")

:gt(index)

Finds all the elements which have index more than the given index. The following example finds all the Tds with index greater than 2.

                   $("td:gt(2)")

In a set of 6 TDs only 3rd, 4th, 5th, 6th TDs will be selected.

:lt(index)

Finds all the elements which have index less than the given index.

:header

Matches all Header elements like h1, h2, h3 and so on.

                        $(":header")

:animated

Matches all elements that are currently being animated.

                        $("div:animated")

Suppose there are 3 DIVs out of which one is being animated. Then the above code will select the currently animated DIV.

 


View Entire Article

User Comments

Title: good   
Name: 00
Date: 2010-01-28 10:44:36 PM
Comment:
thanks
Title: Request   
Name: Pls write more article on JQuery
Date: 2009-05-12 6:46:55 AM
Comment:
Hello Nihar
Please write more articles on JQuery.
Tume lekha ame sahajare khali padhi kam akribu
How is the IDEA?
Excellent Idea...
Title: Ureka   
Name: Lulu
Date: 2009-05-11 10:26:46 AM
Comment:
Really I have been searching this type of article for last 2 months.Thank you Nihar.
Title: Excellent boss   
Name: Sumoon
Date: 2009-05-11 10:23:15 AM
Comment:
Excellent Article boos.Please post tghis type of usefull articles more

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-26 11:07:52 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search