码迷,mamicode.com
首页 > Web开发 > 详细

js-原生js触发器使用

时间:2019-07-23 23:47:23      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:src   oct   load   http   col   fun   ext   htm   doctype   

<!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触发器使用

标签:src   oct   load   http   col   fun   ext   htm   doctype   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!