jquerycssremoveclass

Remove class, but slowly?


So I am using jQuery to remove a class from an element, but it does it immediately. What I'd like is to have the class fade out smoothly, not so harsh.

This is the code I tried, which is not fading out at all:

    $(function() {
$( "a.engine" ).click(function() {
  $( "img.bg" ).removeClass( "intro_effects", 1000 );
  });
});

Any hints as to how to make this fade out?

Thanks much!

* HERE IS THE SITE

http://dev.mediaslave.ca/illustraflex/

Thanks again!


Solution

  • This CSS should animate the properties when you change the class, and you can control it with the transition duration property.

    img.bg {
        transition-property: all;
        transition-duration: 1s;
    }