日期:2014-05-16 浏览次数:20360 次
body{
margin:0;
}
#div1{
border:1px solid red;width:300px;height:300px;
}
<div style="margin-left:-270px;"onmouseover="over1()"onmouseout="out()"id="div1">
gfdgfdfgfdhgfhgfjhgjhgjgh
</div>
var i;var j;
function over2(){
//clearInterval(j);
var div2=document.getElementById("div1");
var m=div2.style.marginLeft;
m=parseInt(m);
if(m<0){
m=m+1;
div2.style.marginLeft=m+"px";
}else{
clearInterval(i);
}
}
function over1(){
i=setInterval("over2()",10);
}
function tt(){
// clearInterval(i);
var div1=document.getElementById("div1");
var m=div1.style.marginLeft;
m=parseInt(m);
if(m>-270){
m=m-1;
div1.style.marginLeft=m+"px";
}else{
clearInterval(j);
}
}
function out(){
j=setInterval("tt()",10);
}