javascript - Make CSS tooltip follow cursor -


i'm creating css based tooltip going have lot of content in tooltip , instead of being in static place wondering there easy way make follow cursor hover on link.

here example of css based tooltip

<div class="couponcode">first link     <span class="coupontooltip">content 1</span> </div>  .couponcode:hover .coupontooltip { display: block; }  .coupontooltip { display: none; background: #c8c8c8; margin-left: 28px; padding: 10px; position: absolute; z-index: 1000; width:200px; height:100px; } 

http://jsfiddle.net/q46xz/

something this

var tooltip = document.queryselectorall('.coupontooltip');  document.addeventlistener('mousemove', fn, false);  function fn(e) {     (var i=tooltip.length; i--;) {         tooltip[i].style.left = e.pagex + 'px';         tooltip[i].style.top = e.pagey + 'px';     } } 

fiddle


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -