How do I animate a background color to transparent in jQuery?

后端 未结 12 1766
慢半拍i
慢半拍i 2020-12-09 14:46

I can animate from transparent to color, but when I tell jquery to animate the backgroundColor: \'transparent\' it just changes to white. Any idea how to fix this?

12条回答
  •  攒了一身酷
    2020-12-09 15:30

    You can use rgba(61, 31, 17, 0.5) color where 0.5 is the opacity. Then if you want transparent set the opacity to 0.0

    $('.myClass').animate({ "backgroundColor" : "rgba(61, 31, 17, 0.0)" }, 1000);
    

提交回复
热议问题