Jquery background animate

前端 未结 6 1351
暖寄归人
暖寄归人 2021-01-13 11:03

Is it possible to animate the background-color in jQuery, because it is not working.

$(\'#something\').animate({
    background :\"red\"
}, 1000         


        
6条回答
  •  -上瘾入骨i
    2021-01-13 11:17

    Using similar syntax (...{background-color :"red"}...), I get the error

    SyntaxError: Unexpected token -

    I was able to get it working by encapsulating the CSS property background-color in single quotes:

    $('#something').animate({
        'background-color' :"red"
    }, 1000);
    

提交回复
热议问题