关于alpha>itarget的问题
window.onload=function(){
var odiv = document.getElementById('div1');
odiv.onmouseover = function(){
startmove(100);
}
odiv.onmouseout = function(){
startmove(30);
}
}
var timer = null;
var alpha = 30;
function startmove(target){
var odiv = document.getElementById("div1");
clearInterval(timer);
timer = setInterval(function(){
var speed = 0;
if(alpha > target){
speed = -10;
}else{
speed = 10;
}
脑子已经懵掉了,求大神解释一下。target的代入值不是100和30么,,var alpha=30, 那么为什么会出现alpha>target的情况啊?就算后面alpha+=speed,那么触发onmouseover时,alpha和target的值一开始都是30,就清除计时器了啊,懵逼=。=大写