Mega Code Archive

 
Categories / JavaScript Tutorial / JQuery
 

Nested map and each function

< html>   <head>     <script type='text/javascript' src='js/jquery-1.3.2.js'></script>     <script type='text/javascript'> $(document).ready(   function() {     var $items = [       'A',       'B',       'C',       'D'     ];     var $i = 0;     var $mapped = $($items).map(       function($key) {         $i++;         return ($i < 2 ? '0' + $i : $i) + ' ' + this;       }     );     $($mapped).each(       function() {         $('ul#ulId').append("<li>" + this + "</li>\n");         }     );   } );     </script>   </head>   <body>      <ul id='ulId'>      </ul>   </body> </html>