浏览器中引入外部jQuery:
var script = document.createElement("script")
script.type = "text/javascript";
script.src = "https://cdn.bootcdn/ajax/libs/jquery/2.2.0/jquery.js";
document.getElementsByTagName("head")[0].appendChild(script);
模拟鼠标点击的三种方法:
$("#root > div > div:nth-child(3) > div").trigger('click');
document.querySelector("#root > div > div:nth-child(3) > div").click();
$("#root > div > div:nth-child(3) > div").click();
获取元素循环打开:
$('.ant-checkbox-input').each(function(index, domEle) {
var openUrl = domEle.value;
console.log(openUrl);
if (openUrl != "") {
window.open(openUrl, "_blank");
}
})
打开新窗口:
window.open(openUrl, "_blank");
window.open(openUrl,'newWin','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,draggable=false,width=500,height=150');
一秒点击一次:
setInterval(function () {
$("#clickme").trigger('click')
}, 1000);
<script type="text/javascript">
var button = document.getElementById("btn");
//每秒执行一次,若按钮状态为可用,进行点击
setInterval(function() {
if (button.disabled == false) {
button.click();
}
},
1000);
</script>