Search code examples
jqueryfading

jQuery addClass fadeIn fadeOut


    $('.a').bind('mouseover',function(){
     $('.a').addClass("b");
     }).bind('mouseout',function(){
     $('.a').removeClass("b");
    });

I want to add fadeIn fadeOut in the above code like :

$('.a').bind('mouseover',function(){
 $('.a').addClass("b").fadeIn('slow');
 }).bind('mouseout',function(){
 $('.a').removeClass("b").fadeOut('fast');
});

But that doesn't work for me...tried to google but that didn't work either.


Solution

  • Your code is working as in bug-free but consider this:

    • fadeOut hides the element and you won't be able to hover over it again.
    • fadeIn on an already visible element won't do anything.