Created
March 2, 2016 14:06
-
-
Save xie-qianyue/f8bca92276677ccbb1f1 to your computer and use it in GitHub Desktop.
jQuery snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Au chargement de la page */ | |
$(document).ready(function() { | |
$("#legend").mouseover(function(event) { | |
createTooltip(event); | |
}).mouseout(function(){ | |
hideTooltip(); | |
}); | |
}); | |
function createTooltip(event){ | |
$('<div class="tooltip">You should write something here.</div>').appendTo('body'); | |
positionTooltip(event); | |
}; | |
function positionTooltip(event){ | |
var tPosX = event.pageX - 10; | |
var tPosY = event.pageY + 20; | |
$('div.tooltip').css({'position': 'absolute', 'top': tPosY, 'left': tPosX}); | |
}; | |
function hideTooltip(){ | |
$('div.tooltip').remove(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment