我需要将脚本变成一个函数
var iterations = document.getElementById('test').innerHTML;
var count = 0;
var button = document.getElementById("click");
var myInterval = setInterval(function test(){
if (count >= iterations) {
clearInterval(myInterval);
}else{
count++;
button.click();}
我尝试但没有工作:
function test(){
var iterations
....
button.click();}}
答案 0 :(得分:0)
尝试使用以下代码
var myInterval = setInterval(test, 0);
function test() {
var iterations, count;
...........do iterations with `count`.....
if (count >= iterations) {
clearInterval(myInterval);
} else {
count++;
button.click();
}
}