亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

物體不運動,不知道問題出在哪兒?報錯信息是Uncaught TypeError: Cannot set property 'width' of undefined

<html>

<head>

<title>多物體運動</title>

<meta charset="utf-8">

<style type="text/css">

*{

margin: 0;

padding: 0;

}

ul,li{

list-style: none;

}

ul li{

width: 200px;

height:100px;

background: yellow;

margin-bottom: 20px;

}

</style>

<script type="text/javascript">

window.onload=function(){

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

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

lis[i].onmouseover=function(){

startMove(this,400);

}

lis[i].onmouseout=function(){

startMove(this,200);

}

}

}

var timer=null;

function startMove(obj,iTarget){

clearInterval(timer);

timer=setInterval(function(){

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

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

? ? ? ? ? ? ? if (obj.offsetWidth==iTarget) {

? ? ? ? ? ? ? clearInterval(timer);

? ? ? ? ? ? ? }

? ? ? ? ? ? ? else{

? ? ? ? ? ? ? obj.sytle.width=obj.offsetWidth+speed+'px';

? ? ? ? ? ? ? }

},50)

}

</script>

</head>

<body>

<ul>

<li></li>

<li></li>

<li></li>

</ul>

</body>

</html>


正在回答

2 回答

style拼錯了

0 回復 有任何疑惑可以回復我~
#1

not_afraid 提問者

謝謝
2016-05-17 回復 有任何疑惑可以回復我~

{obj.sytle.width=obj.offsetWidth+speed+'px'; } ?其中style 錯了

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

舉報

0/150
提交
取消

物體不運動,不知道問題出在哪兒?報錯信息是Uncaught TypeError: Cannot set property 'width' of undefined

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號