为什么不动(js动画),帮帮我

时间:2018-03-16 08:31:16

标签: javascript

为什么不动?

understanding the scopes

function move(){
  console.log(moveoffset+"out");
  while(moveoffset<offsetX){
    console.log(moveoffset+"moveoffsetWhileIn");
    $('.move').style.left=moveoffset+"px";
    setTimeout(function(){
          moveoffset++;
    },1000);
    console.log(offsetX+"offsetX");
  }
}
move()

1 个答案:

答案 0 :(得分:1)

1。)未提供moveoffsetoffsetX的值

2。)使用jQuery时,$('.move').css('prop', 'value')是正确的方法

3。)在setTimeout中,您正在递增moveoffset,但您没有使用此递增值来更新left属性