Wednesday, September 26, 2012

jQuery image selector


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

$('image')

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

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

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

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

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

Search Flipkart Products:
Flipkart.com

No comments: