问答详情
源自:2-1 JS速度动画

clearInterval(my_Time); 怎么不起作用啊 ?

function startMove () {

var oDiv = document.getElementById('box');

my_Time=setInterval(function(){

if(oDiv.offsetLef==0){

clearInterval(my_Time);

}else{

oDiv.style.left = oDiv.offsetLeft+1+"px"; 

}

},30);

};


提问者:xiaoqiao321 2016-02-21 23:14

个回答

  • 慕容6759333
    2016-02-22 09:52:10
    已采纳

    function startMove () {
        var oDiv = document.getElementById('box');
        my_Time=setInterval(function(){
            if(oDiv.offsetLefT==0){
                clearInterval(my_Time);
            }else{
                oDiv.style.left = oDiv.offsetLeft+1+"px"; 
            }
        },30);
    };

    第四行offsetLeft没打对!