JQuery for each Loop example

jQuery.each() function. 
In this article,I will explain How to use JQuery for each Loop with example.The jQuery library provides a jQuery .each() method, which will loop through each  matched element.
The jQuery .each() function is used to loop through each matched element.

Syntax:
.each(function(index,Element))
Example: JQuery for each Loop example
<html>
<title>jQuery.each() function example. 
</title>
<head>
 <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<script>
   var arr = [ "one", "two", "three", "four", "five" ];
   jQuery.each(arr, function() 
{
   alert(this)//Alert the text of each array element
    });
  </script>
</html>


Example:jQuery.each() JSON Example
<html>
<title>jQuery.each() JSON Example</title>
<head>
 <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<script>
   var obj = { one:1, two:2, three:3, four:4, five:5 };
   jQuery.each(obj, function(i, val)
{
     alert(i+'-'+val);//Alert the text of each Json array element
    });
</script>
</html>



I hope,this example will help you to use JQuery for each Loop