第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

簡單的動態(tài)伸縮為啥就是跑不起來呢?為什么瀏覽器工具會顯示obj.style.width錯誤

簡單的動態(tài)伸縮為啥就是跑不起來呢?為什么瀏覽器工具會顯示obj.style.width錯誤

lulubiu 2017-05-03 16:36:18
<!DOCTYPE?html> <html> <head> <meta?charset="UTF-8"> <title>多物體運動</title> <style> *{margin:?0;padding:?0} .li1{width:100px;height:100px;?margin-bottom:?50px;background-color:?teal;} .li2{width:100px;height:100px;?margin-bottom:?50px;background-color:?teal;} .li3{width:100px;height:100px;?margin-bottom:?50px;background-color:?teal;} </style> <script> window.onload=function(){ var?lis=document.getElementsByTagName('li'); for(var?i=0;i<lis.length;i++){ lis[i].timer=null; lis[i].onmouseover=go(this,400); lis[i].onmouseout=go(this,100); } } function?go(obj,target) { clearInterval(obj.timer); obj.timer=setInterval(function(){ var?speed=(target-obj.offsetWidth)/30; speed=speed<0?Math.floor(speed):Math.ceil(speed); if(obj.offsetWidth==target){ clearInterval(obj.timer); } else{ obj.style.width=obj.offsetWidth+speed+'px'; } },30); } </script> </head> <body> <li></li> <li></li> <li></li> </body> </html>
查看完整描述

1 回答

?
風(fēng)箏_0010

TA貢獻(xiàn)45條經(jīng)驗 獲得超15個贊

因為onclick、onmouseover這種事件一般是賦值未運行的函數(shù),比如lis[i].onmouseout=go; 而不是go()這種執(zhí)行后的,所以你的go函數(shù)直接就在window環(huán)境里面執(zhí)行了,傳入的this是指向window的。

查看完整回答
反對 回復(fù) 2017-05-03
  • 1 回答
  • 1 關(guān)注
  • 1313 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號