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

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

定時器沒起到作用?。???、

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>速度動畫</title>

<style type="text/css">

#div1{ background-color:#000;

? ? ? ?position:relative;

? width:200px;

? height:200px;

? left:-200px;

? ? ?}

#div1 span{

background-color: #C0F;

display:inline-block;

position:absolute;

width: 80px;

height::50px;

left:200px;

top:86px;

}

</style>

<script type="text/javascript">

window.onload=function(){

?var odiv1= document.getElementById('div1');

?odiv1.onmousemove=function(){

? ?starMove();

?}

}

?var timer=null;

?function starMove(){

clearInterval(timer);

var odiv1= document.getElementById("div1");

timer= setInterval(function(){

? ? if(odiv1.offsetLef ==0){

clearInterval(timer);

}

else{

? ? ? ? ?odiv1.style.left=odiv1.offsetLeft+1+'px';

? ? ? ?}

},30);

}

</script>

</head>


<body>

<div id="div1"><span>share</span></div>

</body>

</html>


正在回答

2 回答

首先,盡量不要用onmousemove去實驗,而是用onmouseover.

其次,odiv1.offsetLef ==0 ? ? ?其中,offsetLef 書寫錯誤,應為offsetLeft.

最后,解決方案,在css部分加上body{margin: 0; padding: 0;} ? ?可使計時器生效。

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

慧女神 提問者

thank you
2016-04-12 回復 有任何疑惑可以回復我~
#2

慧女神 提問者

body{margin: 0; padding: 0;} 可使計時器生效 為啥啊
2016-04-12 回復 有任何疑惑可以回復我~

offsetLeft寫掉了t。。。。。。

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

舉報

0/150
提交
取消

定時器沒起到作用?????、

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

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

幫助反饋 APP下載

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

公眾號

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