Monday, October 1, 2012

jQuery wildcard not equal to selector


The jQuery wildcard not equal to selector is used to filter out all the elements in a page, where the specified attribute does not have the given value.

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


In this post we shall see on how to use the jQuery wildcard not equal to selector to select all the elements in a page which do not have the value RedText for the class attribute.

The following script lists out all the elements in a page which do not have the value RedText for the class attribute

    $("[class!='RedText']").each(function() {
        alert('Wildcard - Not Equal to word:' + $(this).attr('id'));
    });

The following script lists out all the elements in a page which do not have the value RedText for the class attribute on click of the btnWildcardSelector button.

$('#btnWildcardSelector).click(function(event) {
    event.preventDefault();               
    //
    // Wildcard - Not Equal to word
    $("[class!='RedText']").each(function() {
        alert('Wildcard - Not Equal to word:' + $(this).attr('id'));

Search Flipkart Products:
Flipkart.com

No comments: