Monday, October 1, 2012

jQuery wildcard starts with selector


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

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


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

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

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

The following script lists out all the elements in a page whose class attribute starts with the value Red on click of the btnWildcardSelector button.

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

Search Flipkart Products:
Flipkart.com

1 comment:

Cheap FFXIV Gil said...

The place else may anybody get that type of info
in such a perfect method of writing? I have a presentation subsequent
week, and I am at the look for such information.
Buy FFXIV Gil
Buy Final Fantasy XIV CD Key