Please note this post was first written in 2010. The content in in is now outdated, and the plugin is no longer supported
As I’m sure you know, it’s very easy to set a different colour for a link when a user hovers over it using the :hover pseudo class – it’s used pretty much everywhere.
However, wouldn’t it be nice if instead of jumping sharply from one colour to another, the colours subtly fades from one to another and back again? Fortunately I have written a very simple plugin to do just that!
This plugin subtly fades from the default colour of the element to the specified colour when a user hovers over it, and back again when the user leaves the element.
Using the plugin
This plugin required the color animations official jquery plugin. This must be included on the page before the plugin is included.
To use the plugin, simple use the following code:
$('a').hoverFadeColor();
This will make all the links on a page fade to the color specified in the css:hover style and back again.
The options are as follows:
color: the color to fade to on hover. This can be any css color, rgb value or hexadecimal value. If it is not specified, the plugin will use the default css hover value.
fadeTospeed (default 300): the rate at which the element fades to the hover color
fadeFromspeed (default 700) is the rate at which the element fades to the default color
Download
Version 1.1. Released 29 June 2011
jose
hi how are ya.
Im using this in my website, any idea to implement it in divs? cool would be !
bye
Alex Taylor
Do you mean have the entire div fade?
Sean
I’m pretty new to javascript coding. So should I include the jquery “color” script, and then your code in the head of the document? And then place:
$(‘a’).hoverFadeColor();
somewhere in the body of the document BUT before any links? is that right?
Alex Taylor
Close – please have a look at the jQuery tutorials to get started.
sl
Hi, im using this too, but some time function is stopping , color not fade .Maybe you know how eliminate this problem
Alex Taylor
Can you please give me an example of it not working, and the browser used?
Jeff
When you hover out from a visited link, the visited link color is replaced by the default link color. Is there any way to work around this?
alemar
Hi! Very useful script, thx! Is it compatible also with IE8? It seems not… 🙁
Mike
Thank you mate, I’ve been looking for something like this for ages!