麻烦有时间无聊的帮我看下 onmouseout这个事件为什么没反应
javascript吧
全部回复
仅看楼主
level 1
bihongbin3027 楼主
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
level 1
oDiv.offsetLeft >= insurance,
当onmouseover事件之后,进入onmouseout事件时,你的offsetLeft的值为100,而你传入的insurance为-100,你的判断恒成立,所以不走else了
2013年01月14日 12点01分 2
1