jQuery: how to fade between classes?

前端 未结 4 1219
一个人的身影
一个人的身影 2020-12-19 07:40

I need to be able to fade between classes and seamlessly transition any and all styles being applied to the element and its children. How can this be done using jQuery? I kn

4条回答
  •  北海茫月
    2020-12-19 08:16

    jQuery UI has a toggleClass function that has an argument for duration:

    http://jqueryui.com/demos/toggleClass/

    For example, I do this on one of my sites (fade in/out the light class and fade/in out the dark class):

    $('body').toggleClass('light', 250).toggleClass('dark', 250);
    

提交回复
热议问题