removeClass and fade animation

后端 未结 4 817
抹茶落季
抹茶落季 2021-01-19 01:46

I have this code

  • LINK1
相关标签:
4条回答
  • 2021-01-19 02:10

    You can't fade from one class to another. You have to tell jQuery what properties to animate in the .animate() method.

    To get the next li element, use .next().

    0 讨论(0)
  • 2021-01-19 02:13

    AFAIK i dont think you can add a fadeOut() to a removeClass(). Someone correct me if i'm wrong!

    0 讨论(0)
  • 2021-01-19 02:15

    not sure if you can do this with straight jQuery, but I know jQuery UI has a modified removeClass() that lets you add a duration to remove the class over jQuery UI Docs

    0 讨论(0)
  • 2021-01-19 02:19

    Yeah, you could do this with some CSS3.

    You just add the following to .current.

    .current{
        color: #f00;
        background-color: #000;
        transition: color 0.5s, background-color 0.5s;
        -webkit-transition: color 0.5s, background-color 0.5s; /* Safari */
    }
    

    Obviously you'll need to change color/background-color to the attributes you'd like to animate. Otherwise, Cubed Eye's suggestion of including JqueryUI is great, as the removeClass in jQueryUI will do it all for you..

    0 讨论(0)
提交回复
热议问题