Qvffmlqdqlfjo
New Member
I need to get the x and y coordinates of where I clicked on an HTML5 canvas element. I did the following for the y coordinate:\[code\] $("#my_canvas").click(function(event) { alert(Math.floor(event.clientY-$(this).offset().top)); });\[/code\]This gives me what appears to be the correct y coordinate. The problem is if you scroll down, \[code\]clientY\[/code\] gets smaller because it seems to be measuring the y coordinate on the screen, disregarding the scrolling. So the above gives a negative number. What is the proper way to get the x and y coordinate?