1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| <script>
// création conteneur info-bulle
var oBulle = document.createElement('DIV');
oBulle.id = 'info_bulle';
document.body.appendChild(oBulle);
var oClone,
oInfo = document.querySelectorAll('.HoverfunctionMeps'),
i, nb = oInfo.length;
for (i = 0; i < nb; i += 1) {
oInfo[i].onmouseover = function(e) {
e = e || window.event;
// récup. élément
oClone = this.querySelector('.bulle');
if( oClone){
// copie de l'information
oClone = oClone.cloneNode(true);
// contenu visible
oClone.style.display = 'block';
// place
oBulle.style.left = (e.clientX + 10) + 'px';
oBulle.style.top = (e.clientY + 10) + 'px';
oBulle.appendChild(oClone);
// affiche
oBulle.style.display = 'block';
oBulle.style.background = '#DAE7FA';
};
};
oInfo[i].onmouseout = function() {
// vide le contenu
while (oBulle.firstChild) {
oBulle.removeChild(oBulle.firstChild);
}
// masque
oBulle.style.display = 'none';
};
}
</script> |
Partager