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
Post a Comment