Friday 8 July 2011

jQuery Each() Method

The jQuery library provides a method, Each(), which will loop through each element of the target jQuery object.


$( "#selector" ).each(

// For each item in the "selector", run this code. The "index" is the
// loop iteration index on the current element.
function( index ){

// Bind the onclick event to simply alert the
// iteration index value.
$( this ).bind (
"click",
function(){
alert( intIndex + " of " + $( "#selector" ).length);
}
);
}
);

No comments:

Post a Comment