HTML
<input id="videoInput" type="file" style="display: none" />
<button type="submit" id="videoUploadInput">上传文件</button>
JS
$('#videoUploadInput').click(function (e) {
e.preventDefault()
setTimeout(function() {
document.getElementById('videoInput').click()
}, 2000)
})
The initial positioning reason is that the click event is triggered by the callback function. At this time, event.isTrusted is false (this attribute is currently only supported in IE and Firefox), rather than being actively triggered by the user, that is, this event is not Trusted by the browser.
http://stackoverflow.com/ques...
http://stackoverflow.com/ques...
1. Change the delayed 2000 to 1000
Link description
2. Delayed processing functions are executed immediately
setTimeout((function(){})(),2000)