ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

Jquery - For Each function

.each( function(index, Element) ) :
This is JQuery function used to iterate through each matched element. This function is generally used to iterate through similar elements to apply common functionality.

Check below simple example to understand this function:
This is simple HTML unordered list on page


<ul>
    <li>Kapil</li>
    <li>Baheti</li>
</ul>

Now you can iterate through each <li> using below jquery function:

<script>

$('li').each(function(index) {
    alert(index + ': ' + $(this).text());
});
</script>


Output will be
0: Kapil
1: Baheti

1 comment: