<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RunJS</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript" >
$(function(){
    $("#open").click(function(){
    // $("#upload").trigger("click");
        var myEvent = new Event('click');
        var e = document.createEvent("MouseEvents");
        e.initEvent("click", true, true);              //这里的click可以换成你想触发的行为
        document.getElementById('upload').dispatchEvent(e);
    });
});
</script>
</head>
<body>
<button id="open">Hello RunJS!</button>
<input type="file" id="upload" style="display:none;">
</body>
</html>

 

相关文章:

  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-09-16
相关资源
相似解决方案