jqueryjquery-uifadeuiswitchtoggleclass

Can you make toggleClass animation without jQuery UI?


Can I make this: http://jqueryui.com/demos/switchClass/default.html without jQuery UI?

Basically I have a simple site which the body has a class named: '.bgone'.

.bgone has background color: #ccc and I want to toggle the .bgtwo of which backgroundcolor is #999 with the fade effect.

Is it possible with only jQuery?

Thanks


Solution

  • Unfortunately, to fade between background colors, you need JQuery UI or something similar. You might try this color animation plugin, or alternatively, use CSS3 transitions and simply use jQuery to toggle animated classes.

    Here is an example of CSS3 color animation with a JavaScript/JQuery trigger: http://jsfiddle.net/6nRj2/