好吧,setInterval()和setTimeout()这两个function之前有见过,网站的代码里也有,但一直没留意。应该早就学习的,但今天才真正了解它们真正的作用。

setInterval(function,milliseconds)以millisecond(1/1000秒)为单位不停地执行某一个function

setTimeout(function,milliseconds)以millisecond为单位设置某个function超时


setInterval(function(){
    alert("Hello")
}, 3000);
function setbgColor()
{
    document.bgColor="#000000";
}
setTimeout(setbgColor, 1000);

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s