I found the answer!
I did a bit of maths (it was fun this one, because i solved it) And this is the eventual function I needed to come up with. Set an <a>
tag with a class of hoverInfo
and then the bar 'users' (or whatever you want to call it) will seemingly crossfade between the two with the new information being gathered from the 'rel' statement. Or data. or whatever. :P
js-fiddle:
http://jsfiddle.net/8h5CW/
jQuery code:
$(".hoverInfo").hover(
function () {
var tmpInfo = $(this).attr("rel");
$("#hoverInfo").css("display","none").html(tmpInfo);
var dW = $("#defaultInfo").outerWidth();
var hW = $("#hoverInfo").offset().left + $("#hoverInfo").outerWidth();
var defX = $("#defaultInfo").position().left;
var newPos = (defX-(hW-dW));
$("#hoverInfo").css("left",newPos+"px");
$("#defaultInfo").fadeOut(1000);
$("#hoverInfo").fadeIn(1000);
},
function() {
$("#defaultInfo").fadeIn(1000);
$("#hoverInfo").fadeOut(1000);
}
);
HTML:
<div id="users" style="position: relative; display: block; border: 1px solid #00f; width: 500px; padding: 10px; height: 20px;">
<span id="defaultInfo" style="position: relative; float: right;">
I would like this to fade out yes.</span>
<span id="hoverInfo" style="position: absolute;"></span>
</div>
After testing on my site, For some reason in the page that I wanted to use it on I had to reset the .LEFT each time, so instead of:
$("#hoverInfo").css("display","none").html(tmpInfo);
I just changed it to:
$("#hoverInfo").css("left","0px").css("display","none").html(tmpInfo);
If anyone can think of a quicker, smarter way to do this, I would love to know about it.
Thank you for your answers, and I hope this helps somebody else. I shall be using this function alot in the future