Wednesday, September 26, 2012

jQuery dropdown selector


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

$('select')

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

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

    $('select').each(function() {
        alert('DropDown: ' + $(this).attr('id'));
    });

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

$('#btnTypeSelector').click(function(event) {
    event.preventDefault();               
    //
    // Dropdown - Type Selector
    $('select').each(function() {
        alert('DropDown: ' + $(this).attr('id'));

Search Flipkart Products:
Flipkart.com

No comments: