title: clear file input field using jQuery
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/680241/blank-out-a-form-with-jquery">Blank out a form with jQuery</a>  </p>
  </blockquote>
  
  
  
  <p>I am using a jQuery function to clear all my form values.</p>
  
  <pre><code>$.fn.clearForm = function() {
    return this.each(function() {
      var type = this.type, tag = this.tagName.toLowerCase();
      if (tag == 'form')
        return $(':input',this).clearForm();
      if (type == 'text' || type == 'password' || tag == 'textarea')
        this.value = '';
      else if (type == 'checkbox' || type == 'radio')
        this.checked = false;
      else if (tag == 'select')
        this.selectedIndex = -1;
    });
  };
  </code></pre>
  
  <p>the problem with above function is it does not reset the file input field. is there anyway i could extend the function and make it to work with clearing file input field as well.</p>
  
  <p>here is file input field HTML code i am using.</p>
  
  <pre><code>&lt;section&gt;&lt;label for="productimg"&gt;Picture&lt;br&gt;&lt;/label&gt;
      &lt;div&gt;&lt;input type="file" id="productimg" name="productimg"&gt;&lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>thank you..</p>