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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

第一次寫的JS動(dòng)畫,不知道為什么動(dòng)不了

第一次寫的JS動(dòng)畫,不知道為什么動(dòng)不了

Mrshoushou 2016-10-24 22:02:06
<!DOCTYPE html><html><head> <title>JS Flash</title> <meta charset="utf-8"> <style type="text/css"> body,div,span{ margin: 0; padding: 0;}#div1{ width: 200px; height: 200px; background: red; position: relative; left: -200px; top:0; }#div1 span{ width: 20px; height: 50px; background: blue; position: absolute; left: 200px; top: 75px;} </style> <script type="text/javascript">?window.onload=function(){? var oDiv=document.getElementById('div1');? oDiv.onmouseover=function(){? startMove();? }? oDiv.onmouseover = function(){? startMove1();? }?}?var timer=null;?function startMove(){? clearInterval(timer);? setInterval(function(){? var oDiv=document.getElementById('div1');? if(oDiv.offsetLeft == 0){? clearInterval(timer);? }? else{? oDiv.style.left=oDiv.offsetLeft+10+'px';? }? },30)?}?function startMove1(){? clearInterval(timer);? setInterval(function(){? var oDiv=document.getElementById('div1');? if(oDiv.offsetLeft == -200){? clearInterval(timer);? }? else{? oDiv.style.left=oDiv.offsetLeft-10+'px';? }? },30)?} </script></head><body><div id="div1"> <span id="share">分享</span></div></body></html>
查看完整描述

3 回答

已采納
?
李曉健

TA貢獻(xiàn)1036條經(jīng)驗(yàn) 獲得超461個(gè)贊


oDiv.onmouseover=function(){
????startMove();
}
oDiv.onmouseover?=?function(){
????startMove1();
}
//因?yàn)楹竺嬉粋€(gè)onmouseover?會(huì)覆蓋前面一個(gè)?onmouseover?,所以你就看不到效果


查看完整回答
1 反對(duì) 回復(fù) 2016-10-24
  • Mrshoushou
    Mrshoushou
    謝謝,謝謝。。。。真是太感謝了,繼續(xù)努力奮斗在前端自學(xué)路上
  • Mrshoushou
    Mrshoushou
    大神,我把鼠標(biāo)移出事件改成了onmouseout 后,測(cè)試的確能動(dòng)了,但是在抽風(fēng),前后前后的跳動(dòng)。。。。求解
  • 李曉健
    李曉健
    因?yàn)槟愕?timmer沒有用呀,你只是定義了,沒有賦值,所以定時(shí)是沒有取消,卻一直在累加,就會(huì)出現(xiàn)很多的定時(shí)器同時(shí)執(zhí)行,就會(huì)出現(xiàn)抽風(fēng)的情況。 大概應(yīng)該這是樣的 timer = setInterval(function(){xxxxx},30)
點(diǎn)擊展開后面2
  • 3 回答
  • 0 關(guān)注
  • 2171 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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