Return to Snippet

Revision: 4754
at January 19, 2008 12:05 by 1man


Initial Code
//Grab the original BG color of the link
var originalBG = $(".animate").css("background-color"); 
//The color you want to fade too
var fadeColor = "#CCCCCC"; 

//Now animate on links with class = animate
$(".animate").hover( 
	function() { 
		$(this)
			//Fade to the new color
			.animate({backgroundColor:fadeColor}, 750)
			//Fade back to original color
			.animate({backgroundColor:originalBG},750) 
		}, 
	function(){
			
		}
	);

Initial URL


Initial Description
Found this quick little bit of code on the Google jQuery discussion group. It simply fades the background image of a link you have hovered over to a certain color, then fades it back to the original color.

Initial Title
jQuery Link Background Quick Fade

Initial Tags
javascript, jquery

Initial Language
JavaScript