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

Js语言如下 不知道为什么没有动画效果

window.onload = function(){

var share = document.getElementById('share'),

content = document.getElementById('content');

share.onmouseover = function(){

share.style.backgroundColor = '#FF0';

shareFun();

};

}

var timer = null;

function shareFun (){

var share = document.getElementById('share'),

content = document.getElementById('content');

// clearInterval(timer);

timer = setInterval(function(){

content.style.left = (content.offsetLeft+10)+'px'; 

console.log(content.offsetLeft);

},30)

}


提问者:慕移动3658766 2017-07-14 14:53

个回答

  • qq_孙振华_0
    2017-07-19 15:26:45

    感觉你没有明确自己要做什么

    share.style.backgroundColor = '#FF0'这句的代码书写格式好像不是这样的吧  记不太清了

    1楼的说的也没错  那的确有问题

  • weibo_阿难呢_0
    2017-07-16 15:05:14

    content.style.left = (content.offsetLeft+10)+'px';    这句有问题,不用带括号吧?