Monday, October 1, 2012

jQuery wildcard ends with selector


The jQuery wildcard ends with selector is used to filter out all the elements in a page, where the specified attribute’s value ends with the given value.

[<attribute name>$= <attribute value>]


In this post we shall see on how to use the jQuery wildcard ends with selector to select all the elements in a page whose class attribute ends with the value
Text

The following script lists out all the elements in a page whose class attribute ends with the value Text

    $("[class$='Text']").each(function() {
        alert('Wildcard - Ends with substring:' + $(this).attr('id'));
    });

The following script lists out all the elements in a page whose class attributes ends with the value Text on click of the btnWildcardSelector button.

$('#btnWildcardSelector).click(function(event) {
    event.preventDefault();               
    //
    // Wildcard - Ends With substring
    $("[class$='Text']").each(function() {
        alert('Wildcard - Ends with substring:' + $(this).attr('id'));

Search Flipkart Products:
Flipkart.com

No comments: