setInterval setTimeout(定时器)

来源:互联网 发布:淘宝快递软件 编辑:程序博客网 时间:2024/05/18 01:38

setInterval:间隔设定时间循环显示

setInterval(函数名,间隔时间);

function active(){
alert('美女');
}
setInterval(active,5000);


setTimeout:延时显示,不循环

setTimeout(函数名,间隔时间);

function active(){
alert('你今天真好看!');
}
setTimeout(active,2000);


clearInterval:关闭定时器

clearInterval(定时器);

fn=setInterval(active,1000);//给定时器一个命名
lbox.onmouseover=function(){
clearInterval(fn);
}

原创粉丝点击