Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  194] [ 2]  / answers: 1 / hits: 134391  / 14 Years ago, fri, december 3, 2010, 12:00:00

I have a script:



$('#hfont1').hover(
function() {
$(this).css({color:#efbe5c,font-size:52pt}); //mouseover
},
function() {
$(this).css({color:#e8a010,font-size:48pt}); // mouseout
}
);


how can i animate it or slow it down, so it wont be instant ?


More From » jquery

 Answers
12

Just use .animate() instead of .css() (with a duration if you want), like this:



$('#hfont1').hover(function() {
$(this).animate({color:#efbe5c,font-size:52pt}, 1000);
}, function() {
$(this).animate({color:#e8a010,font-size:48pt}, 1000);
});


You can test it here. Note though, you need either the jQuery color plugin, or jQuery UI included to animate the color. In the above, the duration is 1000ms, you can change it, or just leave it off for the default 400ms duration.


[#94743] Wednesday, December 1, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dominickmackenziet

Total Points: 583
Total Questions: 101
Total Answers: 117

Location: Saint Lucia
Member since Wed, Feb 8, 2023
1 Year ago
dominickmackenziet questions
Wed, Apr 7, 21, 00:00, 3 Years ago
Fri, Feb 12, 21, 00:00, 3 Years ago
;