问题
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);
});
回答1:
You have to add colors plugin to make it work. That is stripped from core.
回答2:
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;
}
回答3:
See the answer to this question: jQuery: animate text color for input field?
You cannot animate css text color with jQuery.
回答4:
You have to use jQuery color plugin to make color animation work.
回答5:
You can use this:
$('#demodiv').animate({color: '#E4D8B8'})
See more here: http://www.bitstorm.org/jquery/color-animation/
来源:https://stackoverflow.com/questions/7516407/jquery-animate-text-color