javascript - display top left corner of div relative to mouse click event -
using javascript (jquery not available here) how display top left corner of div relative mouse click location? following seems work until have scroll page , becomes inaccurate.
function myjsfx() { var div1 = document.getelementbyid('notecontent'); div1.style.display = "block"; div1.style.top = event.clienty + 'px'; div1.style.left = event.clientx + 'px'; }
use window.scrolly
, window.scrollx
scrolling offsets. can subtract the window scroll position values have relative position value.
Comments
Post a Comment