首页 > Web开发 > 详细

js-原生js触发器使用

时间:2019-07-24 00:51:50      阅读:78      评论:0      收藏:0      [点我收藏+]
<!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>

 

js-原生js触发器使用

原文:https://www.cnblogs.com/jkr666666/p/11235167.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!