You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
举例:
var i = 0; //定义一个变量i
var t = setInterval(function(){
if(i === 60){
clearInterval(t); //假如i是60,则清除此定时器,结束循环回调
}else{
i++;
console.log(i);
}
},1000);
var t = setTimeout(function(){
console.log("OK"); //一秒后在控制台输出字符串"OK"
},1000);
offsetLeft与style.left的区别
offsetLeft 获取的是相对于父对象的左边距, left 获取或设置相对于具有定位属性(position定义为relative)的父对象 的左边距。
style.left 返回的是字符串,如28px,offsetLeft返回的是数值28,如果需要对取得的值进行计算,还用offsetLeft比较好。
math取值举例:
setInterval与setTimeout()定时器的区别:
setInterval()是一种定时器,它按照指定的设置时间(以毫秒计)来调用函数的方法。clearInterval()是结束定时器的循环调用函数。
setTimeout()同理也是一种定时器,对应的结束定时的方法是clearTimeout()。与setInterval()不同的是,此定时器只执行一次。
The text was updated successfully, but these errors were encountered: