jquery - How to clear File Input -


below part of jquery code have displays file input , "clear file" button.

var $imagefile = $('<input />').attr({     type: 'file',     name: 'imagefile',     class: 'imagefile' });  $image.append($imagefile);  var $imageclear = $('<input />').attr({     type: 'button',     name: 'imageclear',     class: 'imageclear',     value: 'clear file' });  $image.append($imageclear); 

now reason have "clear file" button because if click on button, clear in file input. how code clears file input when click on "clear file" button?

this should work:

$imageclear.on('click', function() {      $imagefile.val('');  }); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -