bom延迟方法.间隔执行

<script>
// 延时方法
// window.setTimeout(sto,3000);
// function sto(){
// alert('123');
// window.setTimeout(sto,3000);
// }
// 间隔执行
var c1 = 0;
var c2 = 0;
var arr = Array();
arr.push(window.setInterval("sit1()", 500));
arr.push(window.setInterval("sit2()", 500));

function sit1() {
document.getElementById('s1').innerText = ++c1;
}

function sit2() {
document.getElementById('s2').innerText = ++c2;
}

function stop() {
for(var i in arr) {
window.clearInterval(arr[i]);
}
}
// window.clearInterval(1);
// alert(x);
// alert(y);
</script>

原文地址:https://www.cnblogs.com/zhushijun/p/6747087.html