Mouse div position

I have a floating div with dynamic content like this

<div id="rollover" style="display:none;background:#ffff99;width:150px;position:absolute;z-index:9999">
    <div id="rollover_content" style="padding:4px;border:1px solid"></div>
</div>

Event handlers extract the appropriate content and set the innerHTML of the internal DIV. How can I put the top / left part of a div as close as possible to the mouse position?

jQuery is available on the page if that helps.

thank

+3
source share
3 answers

I believe you want the jQuery UI Position plugin . More details here .

+2
source

Assuming that ethis is a parameter in the event handler:

$("#rollover").css({left:e.pageX + "px", top:e.pageY + "px"});
+2
source

Source: https://habr.com/ru/post/1736203/


All Articles