Each function and map array : each « jQuery « JavaScript Tutorial

Home
JavaScript Tutorial
1.Language Basics
2.Operators
3.Statement
4.Development
5.Number Data Type
6.String
7.Function
8.Global
9.Math
10.Form
11.Array
12.Date
13.Dialogs
14.Document
15.Event
16.Location
17.Navigator
18.Screen
19.Window
20.History
21.HTML Tags
22.Style
23.DOM Node
24.Drag Drop
25.Object Oriented
26.Regular Expressions
27.XML
28.GUI Components
29.Dojo toolkit
30.jQuery
31.Animation
32.MS JScript
JavaScript Tutorial » jQuery » each 
30.32.8.Each function and map array
<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){

      var anArray = ['one','two','three',4];
      var anObject = {one:1, two:2, three:3};

      $.each(anArray,function(n,value){
        document.write('['+n+']='+value);
      });

      $.each(anObject,function(n,value){
        document.write('['+n+']='+value);
      });
        });
    </script>

  </head>
  <body>
    <body>
        <p id="followMe">Follow me!</p>
    </body>
</html>
30.32.each
30.32.1.Loop through each tag
30.32.2.each function callback
30.32.3.Each span tag
30.32.4.For each array element
30.32.5.For each function with index and value
30.32.6.Use Each Function To loop through Selected Item
30.32.7.Each function and array
30.32.8.Each function and map array
30.32.9.Use 'return' to break out of each() loops early.
30.32.10.Get each loop index
30.32.11.Use foreach to create li
30.32.12.Append value with each function
30.32.13.Return true as continue statement
30.32.14.Use each function to add class
30.32.15.Hard code value into each function
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.