定时器点击按钮"/>
JS定时器点击按钮
//单次定时器
setTimeout(function() {
var e = document.createEvent("MouseEvents");e.initEvent("click", true, true);
document.getElementById("loginbtn").dispatchEvent(e);
}, 2000);
//循环定时器
setInterval(function() {var e = document.createEvent("MouseEvents");
e.initEvent("click", true, true);
document.getElementById("loginbtn").dispatchEvent(e);
}, 2000);
//去掉定时器的方法
window.clearInterval(e);
<button id = "loginbtn" type ="button" class="btn btn-primary block full-width m-b">登陆</button>
更多推荐
JS定时器点击按钮
发布评论