is this jquery each a closure? If so, how can I fix this?
<p>I am making dynamic forms, while the user selecting the menu from my select options. After they select the option from my select element I generate a form with required elements. All works fine.</p>

<p>Once all done, I send the from to another function to validate. In the validate function I am using <code>$.each</code> function to get elements from the form.</p>

<p>The issue is that the first time I get 'consoled' form one time, second time I am 'consoled' the new for 2 times(but same form), when I am sending the 3rd form to function and put into each loop to console, I am getting 3 times the same 3rd form consoled...</p>

<p>I don't want to console or check first form as 1 time and second form to 2 times, 3 one to 3 time to process.</p>

<p>How can i solve this issue?</p>

<p>I put some function where I am getting issues. If need the full functionality let me provide.</p>

<pre><code>var validateForm = function(form){
     console.log('hi')
     var  submit = form.find(':submit'),
          text = form.find(':text'),
          select = form.find('select'),
          checkBox = form.find('checkbox'),
          file = form.find(':file'),
          textarea = form.find('textarea');

          console.log(form.length);

     form.on('click', function(event){

          console.log(event.target);

          for(i=0;i&lt;form.length;i++){
               console.log($(this),i);     
          }
          return false;
     })
} 
</code></pre>

<p>2nd time each or for loop console like this(2 times):</p>

<pre><code>&lt;input id="salesSubmit" type="submit" value="Send" name="salesSubmit"&gt;
ecomNation.js (line 16)

Object[fieldset]0

ecomNation.js (line 19)
&lt;input id="salesSubmit" type="submit" value="Send" name="salesSubmit"&gt;
ecomNation.js (line 16)

Object[fieldset] 0
</code></pre>

<p>What is wrong here? How can I fix this?</p>

<p>My whole function (99%) is here :</p>

<pre><code>var validateForm = function(form){
     console.log('hi')
     var  submit = form.find(':submit'),
          text = form.find(':text'),
          select = form.find('select'),
          checkBox = form.find(':checkbox'),
          file = form.find(':file'),
          textarea = form.find('textarea');

          console.log(form.length);

          form.on('click', function(event){

      console.log(event.target);

      for(i=0;i&lt;form.length;i++){
           console.log($(this),i);     
      }
      return false;
 })

}

var enquireyForm = function(option,form){

     var  contactForm = $('#contactForm'),
          fieldSet = contactForm.find('fieldset:last'),
          postUrl = '';

     var generateForm = function(fields){

          var optionalForm = "";

          $.each(fields, function(i,field){
               optionalForm += field.label ? "&lt;label&gt;"+field.label+"&lt;/label&gt;" : '',
               optionalForm += field.type === 'text' ? '&lt;input id='+field.id+' name='+field.name+' type=text&gt;' :
                               field.type === 'textarea' ? '&lt;textarea id='+field.id+' name='+field.name+' &gt;&lt;/textarea&gt;' :
                               field.type === 'checkbox' ? '&lt;input id='+field.id+' name='+field.name+'  type=checkbox&gt;' :
                               field.type === 'submit' ? '&lt;input id='+field.id+' name='+field.name+'  value='+field.value+' type=submit&gt;' :
                               field.type === 'file' ? '&lt;input id='+field.id+' name='+field.name+' type=file&gt;':'';
               optionalForm += field.note ? "&lt;span&gt;"+field.note+"&lt;/span&gt;" : '';

               postUrl = field.url ? field.url : '';

          })
          contactForm.attr('action',postUrl);
          return optionalForm;
     }

     option.on('change',function(){
          fieldSet.empty();
          if(this.selectedIndex !== 0){
               validateForm(fieldSet.append(generateForm(form[$(this).val()])));
          }
     })


}
</code></pre>

<p>my HTML to generate form:</p>

<pre><code>&lt;form id="contactForm" action="" method="post"&gt;
    &lt;legend&gt;Inquiry Form&lt;/legend&gt;
    &lt;fieldset&gt;
        &lt;label&gt;Type of Inquiry*&lt;/label&gt;
        &lt;select id='enquiry'&gt;
            &lt;option selected='selected' value=''&gt;Please select&lt;/option&gt;
            &lt;option value='general'&gt;General&lt;/option&gt;
            &lt;option value='sales'&gt;Sales&lt;/option&gt;
            &lt;option value='careers'&gt;Careers&lt;/option&gt;
        &lt;/select&gt;
    &lt;/fieldset&gt;
    &lt;fieldset&gt;&lt;!-- selected form fields goes here --&gt;&lt;/fieldset&gt;
&lt;/form&gt;
</code></pre>
