js定时器SetInterval与setTimeout
2015-07-02 12:49
686 查看
SetInterval为自动重复,setTimeout不会重复。
setTimeout("function",time) 设置一个超时对象
setInterval("function",time) 设置一个超时对象
clearTimeout(对象) 清除已设置的setTimeout对象
clearInterval(对象) 清除已设置的setInterval对象
function hello(){
alert("hello");
}
var id=window.setTimeout(hello,5000);
document.onclick=function(){
window.clearTimeout(id);
}
SetInterval类似。
setTimeout("function",time) 设置一个超时对象
setInterval("function",time) 设置一个超时对象
clearTimeout(对象) 清除已设置的setTimeout对象
clearInterval(对象) 清除已设置的setInterval对象
function hello(){
alert("hello");
}
var id=window.setTimeout(hello,5000);
document.onclick=function(){
window.clearTimeout(id);
}
SetInterval类似。
相关文章推荐
- js中的数据类型
- json级联城市
- javascript带回调函数的异步脚本载入方法实例分析
- javascript 闭包详解
- 浅谈Javascript线程及定时机制
- JavaScript获得url查询参数的方法
- js跨域请求的5中解决方式
- 一个用于每一天JavaScript示例-SVG中间javaScript画廊
- Extjs中store的多种操作
- JS实现从连接中获取youtube的key实例
- json
- JavaScript权威指南_119_第15章_脚本化文档_15.3-文档结构和遍历-作为节点树的文档
- JS 引用类型和值类型
- javascript实现简单的进度条
- Compiler Theory in JavaScript
- js表单验证
- JavaScript权威指南_118_第15章_脚本化文档_15.2-选取文档元素-document.all
- js监听input等表单输入框的变化事件oninput
- ExtJs 入门教程十八[AJax请求 :Ext.Ajax]
- js如何往数组Array中添加元素