1. setInterval(func, time) 间隔定时器
timer = setInterval(func, time)
clearInterval(timer) 关闭定时器
2. setTimeOut(func, time) 延时定时器
timer = setTimeOut(func, time)
clearTimeOut(timer) 关闭定时器
3. 日期对象 返回值皆为数字
Date = new Date()
Date.getHours()
Date.getHours()
Date.getMinites()
Date.getSeconds()
Date.getFullYear()
Date.getMonth() 所得月为当前月减一 所以 +1 为正解
Date.getDate() 得到日
Date.getDay() 得到星期 且从0开始 对应周日
4. 头像与头像对应资料的延迟显示
在两个DIV间合理交互使用setTimeOut() 与 clearTimeOut()
5. 设置图像滚动
setInterval()
通过设置offSetLeft 与定时器结合 达到定时平移效果
本文介绍了JavaScript中setInterval和setTimeout两种定时器的使用方法及其区别,并解释了如何利用它们实现头像资料延迟显示和图像滚动等功能。同时,还详细说明了日期对象的基本属性和方法。
2万+

被折叠的 条评论
为什么被折叠?



