I have a input, type of file, with display:none
and there is a button.
after clicking the button, the input's event should be fired. In IE, Chrome and Firefox it works but not in Safari!
var elem=$('<input id="ajxAttachFiles" name="fileUpload" type="file" style="display: none;"/>');
if($("#ajxAttachFiles").length==0){
elem.prependTo(".ChProgress");
}
$("#ajxAttachFiles").click();
there is no error in console. I tried this but nothing.
$(document).ready(function(){
$("#btn").on('click',function(){
$("#ajxAttachFiles")[0].click();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<input id="ajxAttachFiles" type="file" style="display:none;">
<button id="btn" type="button">Click me!</button>
See Question&Answers more detail:os