您的位置:首页 > 其它

SetTimeout SetInterval

2009-03-02 15:06 363 查看
setTimeout only one time, so need recursion. So continues running the function one after one

SetInterval continues running, without stoping, and it runs every intervals, without waiting the former stops.

1. SetTimeout

function showTime()

{

var today = new Date();

alert("The time is: " + today.toString());

setTimeout("showTime()", 5000);

}

2. SetInterval

var intervalProcess = setInterval("showTime()", 5000);

function showTime()

{

var today = new Date();

alert("The time is: " + today.toString());

}

clearInterval(intervalProcess);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: