Jquery background animate

前端 未结 6 1354
暖寄归人
暖寄归人 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条回答
  •  暖寄归人
    2021-01-13 11:38

    From the docs,

    The jQuery UI project extends the .animate() method by allowing some non-numeric styles such as colors to be animated. The project also includes mechanisms for specifying animations through CSS classes rather than individual attributes.

    So if you use jQuery UI, you can animate background colors. Just make sure that you use backgroundColor and not background.

    The color animations plugin for jQuery also does it.

    Live Example: http://jsfiddle.net/thai/NXejr/2/

提交回复
热议问题