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

Attribute Filters

[attribute]

Matches elements that have the specified attribute like id, title, name, value etc.

                   $("div[id]")

The above will match all the divs which has a ID.

[attribute=value]

Matches elements that have the specified attribute with a certain value.

                        $("input[class=RedButton]")

The above example will find all the input elements with the class name RedButton. Here attribute is 'class' and value is 'RedButton'.

[attribute!=value]

Matches elements that either don't have the specified attribute or do have the specified attribute but not with a certain value.

                        $("input[class!=RedButton]")

The code will find the input elements which either don't have a class name attribute or have a class name with a value other then 'RedButton'.

[attribute^=value]

Will match elements that have the specified attribute and it starts with a certain value.

                        $("input[id^='txt']")

This code will find all the input elements which have an ID and the ID starts with 'txt'. Other input elements which have an ID but don't start with 'txt' will not be matched.

[attribute$=value]

Matches elements that have the specified attribute and it ends with a certain value.

                   $("input[id$='John']")

This code will find all the input elements which have an ID and the ID ends with 'John'. Other input elements which have an ID but don't start with 'John' will not be matched.

[attribute*=value]

Will match the elements that have the specified attribute and it contains a certain value.

                        $("input[name*='man']")

The code will match all the input elements which have the name attribute and the name attribute contains 'man'.

[attributeFilter1][attributeFilter2][attributeFilterN]

Matches elements that match all of the specified attribute filters.

                        $("input[id][name$='man']")

Finds all inputs that have an id attribute and whose name attribute ends with 'man'.


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-05-08 10:44:54 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search