欢迎您访问我爱IT技术网,今天小编为你分享的javascript教程:【js clearInterval()方法的定义和用法】,下面是详细的讲解!
js clearInterval()方法的定义和用法
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"/> <meta name="author" content="http://www.softwhy.com/" /> <title>window对象的clearInterval()方法 -蚂蚁部落</title> <style type="text/css"> #num{ width:100px; height:100px; text-align:center; line-height:100px; background-color:green; margin:50px auto 0px auto; color:red; } #btdiv{ width:76px; height:76px; margin:0px auto; } </style> <script type="text/javascript"> var a=0; window.onload=function(){ var num=document.getElementById("num"); var bt=document.getElementById("bt"); function jisuan(){ num.innerHTML=a; a=a+1; } var flag=setInterval(jisuan,1000); bt.onclick=function(){ clearInterval(flag); } } </script> </head> <body> <div id="num"></div> <div id="btdiv"><button id="bt">点击取消</button></div> </body> </html>
关于js clearInterval()方法的定义和用法的用户互动如下:
相关问题:js中clearInterval()函数这样写无效,为什么?,求...
答:" clearInterval(intt);//为什么此处无效,不能终止intt " 这不是这个方法的错误,是你的循环变色就没开始变吧,你上面的 var intt = setInterval("changeCo()", 50)石油问题的,你可以看一下这个方法的是不是有问题的,再一个,要不是$('#in1').... >>详细
相关问题:js 如何循环执行同一方法
答:function dometemp(temp){ console.log(temp);}function dometemp1(temp){ console.log(temp); setTimeout(function(){dometemp1('这是通过setTimeout过来的');},1000);}function dometemp2(temp){ console.log(temp);}//方法1:利用循环for(var... >>详细
相关问题:js小白求助,代码如下,谢谢!
答:你的启动时钟函数和停止函数写成一样的了,改掉其中一个的函数名就好了 >>详细
- 【firefox】firefox浏览器不支持innerText的解决
- 【Extjs】Extjs学习过程中新手容易碰到的低级错误
- 【clearInterval】js clearInterval()方法的定义
- 【dom】javascript dom追加内容实现示例-追加内容
- 【checkbox】让checkbox不选中即将选中的checkbox
- 【Array】js中更短的 Array 类型转换-类型转换
- 【append】append和appendTo的区别以及appendChil
- 【ExtJs】ExtJs 表单提交登陆实现代码-表单提交-
- 【addClass】javascript自定义的addClass()方法
- 【Event】jquery下为Event handler传递动态参数的
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
