jQuery Animate not working on background-color property

后端 未结 5 1840
迷失自我
迷失自我 2020-12-21 09:29

I was playing around with the jQuery .animate() function, and ended up trying to change the background-color of one of the divs depend

5条回答
  •  死守一世寂寞
    2020-12-21 10:30

    As per jQuery API docs:

    The .animate() method allows us to create animation effects on any numeric CSS property.

    Animation Properties and Values

    All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color plugin is used)

    emphasis is mine

    Background Color is not a numeric property and so it cannot be animated using .animate().

提交回复
热议问题