Monday, October 1, 2012

jQuery attribute with checkbox type selector


The jQuery attribute with checkbox type is used to filter out all checkbox elements in a page which are checked, the syntax for this selector is.

input[type=checkbox][checked]


In this post we shall see on how to use the jQuery attribute with checkbox type selector to select all the checkboxes which are checked in a page.

The following script lists out all the checkbox elements in the page which are checked 

    $("input[type=checkbox][checked]").each(function() {
    alert('Attribute with checkbox type Selector:' + $(this).attr('id'));
    }); 

The following script lists out all the checkbox elements in a page which are checked, on click of the btnAttributeSelector button.

$('#btnAttributeSelector).click(function(event) {
    event.preventDefault();
    //                          
    // Attribute - Attribute with checkbox type Selector               
    $("input[type=checkbox][checked]").each(function() {
    alert('Attribute with checkbox type Selector:' + $(this).attr('id'));
    }); 
});

Related Post
jQuery attribute Selectors
jQuery id selector
jQuery class selector
jQuery attribute exists selector
jQuery attribute value selector
jQuery attribute with type selector
jQuery attribute with type and value IN selector
jQuery attribute with type and value NOT IN selector
jQuery attribute with dropdown type selector
jQuery attribute with checkbox type selector
jQuery attribute selector Example

Search Flipkart Products:
Flipkart.com

No comments: