Last active
November 20, 2015 10:27
-
-
Save amitpatelx/d084cda55b0205026bc2 to your computer and use it in GitHub Desktop.
Clear selected file - HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Once you select any file from file input, there is no way user can unselect it. | |
//Soluction | |
// Clear any input, including <input type='file' /> | |
// http://stackoverflow.com/a/13351234/517483 | |
window.smartReset = function (e) { | |
e.wrap('<form>').closest('form').get(0).reset(); | |
e.unwrap(); | |
} | |
//Call the function passing jQuery object of selected file element | |
$('#remove_post_sponsor_logo_link').on('click', function(){ | |
smartReset($('#post_sponsor_logo')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment