html:
<div id="box"></div>
js:
var dom = document.getElementById('box');
var clickEvent = document.createEvent("MouseEvents");
clickEvent.initEvent('click',false,false);
dom.dispatchEvent(clickEvent);
html:
<div id="box"></div>
js:
var dom = document.getElementById('box');
var clickEvent = document.createEvent("MouseEvents");
clickEvent.initEvent('click',false,false);
dom.dispatchEvent(clickEvent);
本文标题:js模拟点击元素
本文链接:https://www.haomeiwen.com/subject/pqhkedtx.html
网友评论