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

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

求解:多物體動畫沒有效果

<!DOCTYPE html>
<html lang="en">
<head>
? ?<meta charset="UTF-8">
? ?<title>Title</title>
? ?<script>
window.onload=donghua;
function donghua(){
? ? ? ? ? ?var duix=document.getElementsByTagName("div");
for(var i=0;i<duix.length;i++){
? ? ? ? ? ? ? ?duix[i].style.width=100+"px";
duix[i].style.border="1px solid red";
duix[i].style.height="100px"
duix[i].onmouseover=move(this);
}}
? ? ? ?var timer=null;
function move(xx){
? ? ? ? ? ?clearInterval(xx.timer);
xx.timer=setInterval(function(){
? ? ? ? ? ? ? ?var cc= parseInt(xx.offsetWidth);
if(cc<200){
? ? ? ? ? ? ? ? ? ?cc++;
}
? ? ? ? ? ? ? ?xx.style.width=cc+"px";
},10)
? ? ? ?}
? ?</script>
</head>
<body>
<div>動畫測試一</div>
<div>動畫測試二</div>
<div>動畫測試三</div>
</body>
</html>

正在回答

1 回答

<!DOCTYPE?html>
<html>
<head>
???<meta?charset="UTF-8">
???<title>Title</title>
???<script>
??window.onload=function(){
????donghua();
??}
??function?donghua(){
????var?duix=document.getElementsByTagName("div");
????for(var?i=0;i<duix.length;i++){
??????duix[i].style.width=100+"px";
??????duix[i].style.border="1px?solid?red";
??????duix[i].style.height="100px"
??????duix[i].onmouseover=function(){
????????move(this);
??????}
????}
??}
??var?timer=null;
??function?move(xx){
????clearInterval(xx.timer);
????xx.timer=setInterval(function(){
??????var?cc=?parseInt(xx.offsetWidth);
??????if(cc<200){
?????????cc++;
??????}
??????xx.style.width=cc+"px";
????},10)
??}
??</script>
</head>
<body>
<div>動畫測試一</div>
<div>動畫測試二</div>
<div>動畫測試三</div>
</body>
</html>

更改后的代碼,更改有兩點:

??window.onload=function(){
????donghua();
??}


??????duix[i].onmouseover=function(){
????????move(this);
??????}

之前的形式無法正確調(diào)用函數(shù)!

但是這樣的代碼跑了之后 就會發(fā)現(xiàn),width會一直增長下去,原因在視頻里也提到了,是border的問題,你設(shè)置的是cc++,但是每次增長的是3px。改正的方法可以按照視頻里提到的,也可以把width的設(shè)置放在cc判斷的里面(效果是沒有前面的方法好,而且依舊是每次增加3px)。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕仰1571740 提問者

非常感謝!
2016-04-04 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

求解:多物體動畫沒有效果

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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