1 <script> 2 // 延时方法 3 // window.setTimeout(sto,3000); 4 // function sto(){ 5 // alert('123'); 6 // window.setTimeout(sto,3000); 7 // } 8 // 间隔执行 9 var c1 = 0; 10 var c2 = 0; 11 var arr = Array(); 12 arr.push(window.setInterval("sit1()", 500)); 13 arr.push(window.setInterval("sit2()", 500)); 14 15 function sit1() { 16 document.getElementById('s1').innerText = ++c1; 17 } 18 19 function sit2() { 20 document.getElementById('s2').innerText = ++c2; 21 } 22 23 function stop() { 24 for(var i in arr) { 25 window.clearInterval(arr[i]); 26 } 27 } 28 // window.clearInterval(1); 29 // alert(x); 30 // alert(y); 31 </script>