title: foreach equivalent of php in jquery?
body: <p>Is there a foreach code in JQuery as in PHP?
  I have a code in php,like</p>
  
  <pre><code>&lt;?php foreach ($viewfields as $viewfield): ?&gt;       
  if("&lt;?php echo $viewfield['Attribute']['required'];?&gt;"=='true'){
         $("&lt;span class='req'&gt;&lt;em&gt; * &lt;/em&gt;&lt;/span&gt;").appendTo("#fb_contentarea_col1down21 #label&lt;?php echo $viewfield['Attribute']['sequence_no']?&gt;");
     }
  
  
     if(&lt;?=$viewfield['Attribute']['type'];?&gt;=='text'||&lt;?=$viewfield['Attribute']['type'];?&gt;=='date'||&lt;?=$viewfield['Attribute']['type'];?&gt;=='number'){ 
         $("&lt;input id=input&lt;?=$viewfield['Attribute']['sequence_no'];?&gt; type= 'text' style= 'width:&lt;?=$viewfield['Attribute']['size'];?&gt;px' data-attr=&lt;?=$viewfield['Attribute']['type'];?&gt; &gt;&lt;/input&gt;&lt;br&gt;").appendTo("#fb_contentarea_col1down21 #&lt;?=$viewfield['Attribute']['sequence_no'];?&gt;");
     }
  
  
     else if(&lt;?=$viewfield['Attribute']['type'];?&gt;=='textarea'){
         $("&lt;textarea style= 'width:&lt;?=$viewfield['Attribute']['size'];?&gt;px' data-attr=&lt;?=$viewfield['Attribute']['type'];?&gt; id=input&lt;?=$viewfield['Attribute']['sequence_no'];?&gt;&gt;&lt;/textarea&gt;&lt;br&gt;").appendTo("#fb_contentarea_col1down21 #&lt;?=$viewfield['Attribute']['sequence_no'];?&gt;");
  }
  </code></pre>
  
  
  
  <p>Is there any equivalent of foreach in Jquery? How can I accomplish this same functioality in jQuery?</p>
  
  <p>EDIT 1:</p>
  
  <p>I thought it worked but I get an error. The code and the error message is given below.</p>
  
  <pre><code>for(&lt;?=$viewfield;?&gt; in &lt;?=$viewfields;?&gt;){
  
   if("&lt;?=$viewfield['Attribute']['required'];?&gt;"=='true'){
              $("&lt;span class='req'&gt;&lt;em&gt; * &lt;/em&gt;&lt;/span&gt;").appendTo("#fb_contentarea_col1down21 #label&lt;?php echo $viewfield['Attribute']['sequence_no']?&gt;");
   }
  
   if(&lt;?=$viewfield['Attribute']['type'];?&gt;=='text'||&lt;?=$viewfield['Attribute']['type'];?&gt;=='date'||&lt;?=$viewfield['Attribute']['type'];?&gt;=='number'){ 
              $("&lt;input id=input&lt;?=$viewfield['Attribute']['sequence_no'];?&gt; type= 'text' style= 'width:&lt;?=$viewfield['Attribute']['size'];?&gt;px' data-attr=&lt;?=$viewfield['Attribute']['type'];?&gt; &gt;&lt;/input&gt;&lt;br&gt;").appendTo("#fb_contentarea_col1down21 #&lt;?=$viewfield['Attribute']['sequence_no'];?&gt;");
   }
  
   else if(&lt;?=$viewfield['Attribute']['type'];?&gt;=='textarea'){
              $("&lt;textarea style= 'width:&lt;?=$viewfield['Attribute']['size'];?&gt;px' data-attr=&lt;?=$viewfield['Attribute']['type'];?&gt; id=input&lt;?=$viewfield['Attribute']['sequence_no'];?&gt;&gt;&lt;/textarea&gt;&lt;br&gt;").appendTo("#fb_contentarea_col1down21 #&lt;?=$viewfield['Attribute']['sequence_no'];?&gt;");
   }
  </code></pre>
  
  <p>}</p>
  
  <p>Error message:</p>
  
  <p>syntax error
   for( in Array)</p>
  
  <p>Can someone help me..</p>