javascript - Find element closest to click coordinates -
is there easy way detect closest child element coordinates of mouse click in container?. in case container div ex: <div style="white-space: pre-wrap"> <span>e1</span> <span>\n</span> <span>\n</span> <span>e4</span> <span>e5</span> </div> in above case determine span closest top/left coordinates click took place in div. due line breaks spans don't cover div in click event have access top/left through e.clienty; however, having difficulty traversing spans detect span closest coordinates of click inside div. click handler: function(e){ var yop = e.clienty; } here links might useful document.elementfrompoint : from summary on mdn link: returns element document elementfrompoint method being called topmost element lies under given point. element, specify point via coordinates, in css pixels, relative upper-left-most point in window or frame containing d...