jQuery Animate not working on background-color property

后端 未结 5 1821
迷失自我
迷失自我 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:13

    Just an addition to existing answers: if you don't want to use jQuery UI for this, you can use this jQuery plugin (2.7kB only):

    http://www.bitstorm.org/jquery/color-animation/

    You can download jquery.animate-colors.js or jquery.animate-colors.min.js from the project's website, or include it from CDN:

    
    

    After including you can use color animations the following way:

    $('#demodiv').animate({color: '#E4D8B8'})
    $('#demodiv').animate({backgroundColor: '#400101'})
    $('#demodiv').animate({borderBottomColor: '#00346B'})
    $('#demodiv').animate({borderColor: 'darkolivegreen'})
    $('#demodiv').animate({color: 'rgba(42, 47, 76, 0.1)'})
    

提交回复
热议问题