How do I call a JavaScript function after selecting a file from the Select File window and closing it?
I have a file input element
<input type="file" id="fileid">
How do I call a JavaScript function after selecting a file from the dialog window and closing it?
jQuery("input#fileid").change(function () {
alert(jQuery(this).val())
});
<input type="file" id="fileid" >
the change will function when you put script below the input
<script type="text/javascript">
$(document).ready(function(){
$("#fileid").on('change',function(){
//do whatever you want
});
});
</script>
<script>
function example(){
alert('success');
}
</script>
<input type="file" id="field" onchange="example()" >
This tested code helps you:
$("body").on('change', 'input#fileid',function(){
alert($(this).val());});