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

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -