开发者

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(开发者_JS百科{
            color: '#333'
        }, 600);            
    },
    function(){
        $(this).animate({
            color: '#999'
        }, 600);          
    });


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


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;
}


See the answer to this question: jQuery: animate text color for input field?

You cannot animate css text color with jQuery.


You have to use jQuery color plugin to make color animation work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜