Jquery Each function
HTML:
<ul>
<li>Mango</li>
<li>Book</li>
</ul>
Script:
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
A message is thus logged for each item in the list:
Output
0: Mango
1: Book
1: Book
<ul>
<li>Mango</li>
<li>Book</li>
</ul>
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
In this page (written and validated by A. Gawali) you learned about Jquery Each function . What's Next? If you are interested in completing Jquery tutorial, your next topic will be learning about: Jquery Attributes.
Share On: |