title: TypeError: form is undefined
body: <p>Why do i get error -</p>
  
  <pre><code>TypeError: form is undefined[Learn More]
  </code></pre>
  
  <p>when i submit the form?</p>
  
  <p>What do i need to change?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).on("click", ".edit_save-btn", function(e) {
  
    var element = $(this);
  
    var form = $(this).closest('form')[0];
    for (i = 0; i &lt; form.elements.length; i++) {
      if (form.elements[i].type == 'file') {
        if (form.elements[i].value == '') {
          form.elements[i].parentNode.removeChild(form.elements[i]);
        }
      }
    }
  
  var formData = new FormData(form);
  var act = "edit";
  formData.push({name: 'act', value: 'edit'});
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;form action='#' method='post' enctype='multipart/form-data'&gt;
    &lt;tr id="4" class="fadeSec item"&gt;
      &lt;td class="item_logo"&gt;&lt;input name="file[]" type="file"&gt;&lt;/td&gt;
      &lt;td class="item_name"&gt;&lt;input name="agnt[name]" value="Agency 2" type="text"&gt;&lt;span&gt;*&lt;/span&gt;&lt;/td&gt;
      &lt;td class="item_mainEmail"&gt;&lt;input name="agnt[mainEmail]" value="email@gmail.com" type="text"&gt;&lt;/td&gt;
      &lt;td class="item_contact"&gt;&lt;textarea type="text" name="agnt[contact]"&gt;some details&lt;/textarea&gt;&lt;/td&gt;
      &lt;td class="panel-menu"&gt;
        &lt;div class="edit_msg"&gt;&lt;/div&gt;
  
        &lt;i class="fa fa-refresh fa-spin fa-2x fa-fw edit_form-loader"&gt;&lt;/i&gt;
        &lt;a href="#" class="btn btn-success edit_save-btn"&gt;Save&lt;/a&gt;
  
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>................
  ............. .................  ......................</p>