daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Aug 19th, 2018 65 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. clear file input field using jQuery [closed]
  2. $.fn.clearForm = function() {
  3.   return this.each(function() {
  4.     var type = this.type, tag = this.tagName.toLowerCase();
  5.     if (tag == 'form')
  6.       return $(':input',this).clearForm();
  7.     if (type == 'text' || type == 'password' || tag == 'textarea')
  8.       this.value = '';
  9.     else if (type == 'checkbox' || type == 'radio')
  10.       this.checked = false;
  11.     else if (tag == 'select')
  12.       this.selectedIndex = -1;
  13.   });
  14. };
  15.    
  16. <section><label for="productimg">Picture<br></label>
  17.     <div><input type="file" id="productimg" name="productimg"></div>
  18. </section>
  19.    
  20. $('#myform')[0].reset();
  21.    
  22. $('#form_id').each(function(){
  23.     this.reset();
  24. });
  25.    
  26. var id=$(this).attr('id');
  27.     $(this).replaceWith("<input type='file' id='"+id+"' />");
  28.    
  29. jQuery.fn.reset = function(){
  30.   $(this).each (function() { this.reset(); });
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top