美文网首页
JS两种定时器的使用:转载

JS两种定时器的使用:转载

作者: 黎峰麟 | 来源:发表于2018-06-20 16:12 被阅读11次

文章出处:https://blog.csdn.net/shenyanwei/article/details/68921568
setTimeout只在指定时间后执行一次

<script>  
//定时器 异步运行  
function hello(){  
alert("hello");  
}  
//使用方法名字执行方法  
var t1 = window.setTimeout(hello,1000);  
var t2 = window.setTimeout("hello()",3000);//使用字符串执行方法  
window.clearTimeout(t1);//去掉定时器  
</script>

setInterval以指定时间为周期循环执行

//实时刷新时间单位为毫秒  
setInterval('refreshQuery()',8000);   
/* 刷新查询 */  
function refreshQuery(){  
   $("#mainTable").datagrid('reload',null);  
} 

相关文章

网友评论

      本文标题:JS两种定时器的使用:转载

      本文链接:https://www.haomeiwen.com/subject/ztexyftx.html