Wednesday, September 26, 2012

jQuery checkbox selector


The jQuery checkbox selector is used to filter out all the checkbox elements in a page, the syntax for this selector is.

input[type="checkbox"]


In this post we shall see on how to use the jQuery checkbox selector to select all the checkbox elements in a page without specifying the id or name of element explicitly.

The following script lists out all the checkbox elements in the page

    $('input[type="checkbox"]').each(function() {
        alert('Check Box: ' + $(this).attr('id'));
    });

The following script lists out all the checkbox elements in the page on click of the btnTypeSelector button.

$('#btnTypeSelector').click(function(event) {
    event.preventDefault();               
    //
    // Check Box - Type Selector
    $('input[type="checkbox"]').each(function() {
        alert('Check Box: ' + $(this).attr('id'));

Search Flipkart Products:
Flipkart.com

No comments: