Monday, April 30, 2012

jQuery: .each()

Example of using jQuery .each() function:
jQuery: .each()

<!doctype html>
<head>
 <title>Mobile-Web-App: jQuery</title>
 <meta charset="utf-8">
 <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
 <script type="text/javascript">

  $(document).ready(function(){

   var myArray = ["A", 100, "EF", [1, 2, 3, 4]];
   
   document.writeln("<p>myArray = " + myArray + "</p>");
   
   $.each(myArray, function(index, value){
    document.writeln("<p>index = " + index + " : value = " + value + "</p>");
   });
   
  });
 </script> 
 
</head>
<body>
</body>
</html>


No comments:

Post a Comment