Wednesday, October 3, 2012

jQuery visible selector


The jQuery visible selector is used to filter out all the visible elements in a page.

$("input:visible")

In this post we shall see on how to use the jQuery visible selector to select all the visible elements in a page.

The following script lists out all the visible elements in a page

    $("input:visible").each(function() {
        alert('State - Visible:' + $(this).attr('id'));
    });

The following script lists out all the visible elements in a page on click of the btnStateSelector button.

$('#btnStateSelector).click(function(event) {
    event.preventDefault();               
    //
    // State - Visible
    $("input:visible").each(function() {
        alert('State - Visible:' + $(this).attr('id'));
    });
});

Search Flipkart Products:
Flipkart.com

No comments: