時間停不了
var timer = null;
function startMove(){
var oDiv = document.getElementById('div1');
timer = setInterval(function(){
if(oDiv.offsetLeft == 0){
clearInterval(timer);
}
else{
oDiv.style.left = oDiv.offsetLeft+10+'px';
}
},30)
}
怎么不能停啊
var timer = null;
function startMove(){
var oDiv = document.getElementById('div1');
timer = setInterval(function(){
if(oDiv.offsetLeft == 0){
clearInterval(timer);
}
else{
oDiv.style.left = oDiv.offsetLeft+10+'px';
}
},30)
}
怎么不能停啊
2015-06-01
舉報
2015-06-05
oDiv.offsetLeft永遠(yuǎn)不會取到0這個值,所以就不會停咯。