level 1
window.onload = function(){
var oDiv = document.getElementById('div1');
oDiv.onmouseover = function(){
startMove(0, 10);
};
oDiv.onmouseout = function(){
startMove(-100, -10)
};
}
var timer = null;
function startMove(insurance, october){
var oDiv = document.getElementById('div1');
clearInterval(timer);
timer = setInterval(function(){
if(oDiv.offsetLeft >= insurance){
clearInterval(timer);
}
else{
oDiv.style.left = oDiv.offsetLeft + october + 'px';
}
}, 30);
}
2013年01月14日 10点01分
1
var oDiv = document.getElementById('div1');
oDiv.onmouseover = function(){
startMove(0, 10);
};
oDiv.onmouseout = function(){
startMove(-100, -10)
};
}
var timer = null;
function startMove(insurance, october){
var oDiv = document.getElementById('div1');
clearInterval(timer);
timer = setInterval(function(){
if(oDiv.offsetLeft >= insurance){
clearInterval(timer);
}
else{
oDiv.style.left = oDiv.offsetLeft + october + 'px';
}
}, 30);
}