Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: animate text color

i wanna dynamically change the link color within a hover event. I got the following code so far but it doesn´t work. Any suggestions why? In my oppinion it seems to be right...

    $('.fadelink').hover(function(){            
        $(this).animate({
            color: '#333'
        }, 600);            
    },
    function(){
        $(this).animate({
            color: '#999'
        }, 600);          
    });
like image 795
Mikaelik Avatar asked Sep 22 '11 14:09

Mikaelik


2 Answers

You have to add colors plugin to make it work. That is stripped from core.

like image 91
Arda Avatar answered Nov 15 '22 15:11

Arda


jQuery doesn't support animation of colors, but it can with the color plugin: http://plugins.jquery.com/project/color

However, there's another route you could take, with CSS3, if you don't mind it not working in some older browsers:

.baseClass {
    color:#999; 

    -webkit-transition-property:color; 
    -webkit-transition-duration: 1s, 1s; 
    -webkit-transition-timing-function: linear, ease-in;
}

.baseClass:hover {
    color: #333;
}
like image 45
Joakim Johansson Avatar answered Nov 15 '22 16:11

Joakim Johansson