为了账号安全,请及时绑定邮箱和手机立即绑定

不知道哪错了,就是运行不出来

window.onload=function(){

var aLi=document.getElementsByTagName('li');

for(var i=0;i<aLi.length;i++){

aLi[i].timer=null;

aLi[i].onmouseover=function(){

startMove(this,400);

}

aLi[i].onmouseout=function(){

startMove(this,200);

}

}


function startMove(obj,iTarget){

clearInterval(obj.timer);

obj.timer=setInterval(function()

{

var speed=(iTarget-obj.offsetWidth)/8;

speed=speed>0?Math.ceil(speed):Math.floor(speed);


if(obj.offsetWidth==iTarget)

{

clearInterval(obj.timer);

}

else{

obj.style.Width=obj.offsetWidth+speed+'px';

}

},10)

}


正在回答

2 回答

知道了,谢谢

0 回复 有任何疑惑可以回复我~

obj.style.width中的width小写,js是区分大小写的,你再试试

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
JS动画效果
  • 参与学习       113914    人
  • 解答问题       1502    个

通过本课程JS动画的学习,从简单动画开始,逐步深入各种动画框架封装

进入课程

不知道哪错了,就是运行不出来

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号