I have a tooltip which appears then disappears after a couple of seconds.
function tooltip(msg) {
tooltipStart(msg);
tooltipExit();
}
function tooltipStart(msg) {
$('body').append('<div id="tooltip">'+msg+'</div>');
$('#tooltip').fadeIn(300);
}
function tooltipExit(duration) {
if ( ! duration) {
duration = 2000;
}
$('#tooltip').delay(duration).fadeOut(1000, function() {
$('#tooltip').remove();
});
}
I now want the tooltip to not fade out and be 100% opaque if the user hovers over the tooltip.
Do I need to rewrite the way the tooltip works or is there a way to stop the tooltipExit function when the mouse hovers over it?
This should do the trick!
The stop function stops the animation, and the show function will show the tooltip again. Then when the mouse leaves the tooltip again, after 2 seconds it will start to fade again.