HTML get coordinates/position on click with JS
Is there a way to get a position/coordinates on mouse click? In example if I have an image in a container and I click on it I want to get coordinates(x,y) in that image? I see only 1 solution to make lots of containers on top of image so small(will be like grid) that when I click it will give containers position in js, but I thi开发者_开发知识库nk page will be so freakin slow because of that. Is there any other solution to this?
Get coords of the image (css: top, left) and coords of the mouse click, and do a little math. :-)
This is pretty easy with a JS library like jQuery or prototype.
pseudo code (change to your framework):
cX=event.clientX; cY=event.clientY;
精彩评论