請(qǐng)大神看看為什么鼠標(biāo)移出總是不停抖動(dòng)
<!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>無標(biāo)題文檔</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
#box{
position:relative;
left:-200px;
}
.one{
width:200px;
height:200px;
background-color:red;
float:left;
}
.two{
width:50px;
height:50px;
background-color:blue;
float:left;
margin-top:55px;
}
</style>
<script type="text/javascript">
window.onload=function(){
var odiv=document.getElementById("box");
odiv.onmouseover=function(){
starmove1(0)
}
odiv.onmouseout=function(){
? ?starmove1(-200)
}
}
function starmove1(iTarget){
var timer;
clearInterval(timer);
var odiv=document.getElementById("box");
timer=setInterval(function(){
var speed;
if(odiv.offsetLeft>iTarget){
speed=-10;
}else{
speed=10
}
if(odiv.offsetLeft==iTarget){
clearInterval(timer);
}else{
odiv.style.left=odiv.offsetLeft+speed+"px";}
},30);
}
</script>
</head>
<body>
<div id="box">
<div class="one"></div>
<div class="two">分享</div>
</div>
</body>
</html>
2016-07-29
我也是這個(gè)問題不知道怎么回事,onmouseout就一直出現(xiàn)抖動(dòng)問題,請(qǐng)問你知道怎么回事了么,求指教
2016-06-28
也許是你沒有給timer和speed初始值吧
2016-06-25
我也是這個(gè)原因啊 不知道為什么會(huì)這樣,照理來說直接在函數(shù)中定義應(yīng)該沒問題啊
2016-06-18
猜測(cè)是html結(jié)構(gòu)的原因
2016-06-12
總感覺你設(shè)置的那個(gè)speed有問題、而且定時(shí)器的調(diào)用成立重復(fù)性。。。。我也不確定是不是這樣的