javascript - Saving mouse-click coordinates with the CENTER of click.box as origin -
I am trying to write bits of code in the html webpage so that when the user clicks the mouse within my click box, So the x and y coordinates are saved and then sent to my databases.
But for now, click handler ... even how far I've got:
This works, but the click displays coordinates in a manner that is clear that the original is not the center or top left corner of my clickbox, how do I modify these snippets so that My click-box is located on my webpage, but I get exact coordinates with the center coordinate center of my ClickBox Original ? Thank you in advance,
Coordinate relative to top and left side
coordX = e.pageX - $ ('# clickbox'). Offset (). Left; Coordination = E. Paging - $ ('#clickbox') Offset (). Top; coordinate with the origin of the Clickbox as the center
coordX = e.pageX - $ ('# clickbox'). Offset (). Left - ($ ('# Clickbox') width () * 0.5); Coordination = E. Paging - $ ('#click box') Offset (). Top - ($ ('#clickbox'). Height () * 0.5);
Comments
Post a Comment