Friday, October 5, 2012

jQuery first selector for Dropdown


The jQuery first selector can be used with other type selectors to filter elements specific to the types, here is the syntax to use the first selector with the Dropdown type selector.

$("select:first")

In this post we shall see on how to use the jQuery first
selector with the Dropdown type selector to get the first Dropdown element in the page.

The following script gets the first Dropdown element in the page.

    // Hierarchy - First Dropdown
    alert('Hierarchy - First Dropdown:' + $("select:first").attr('id'));

The following script gets the first Dropdown element in the page on click of the btnHierarchySelector button.

$('#btnHierarchySelector).click(function(event) {
    event.preventDefault();               
    //
    // Hierarchy - First Dropdown
    alert('Hierarchy - First Dropdown:' + $("select:first").attr('id'));
});






Search Flipkart Products:
Flipkart.com

No comments: