Get relative coords of clicked image

A

Andrew Poulos

I have a image in a scrollable DIV. The image is bigger than the display
size of the DIV. How do I get the coordinates of a mouse click on the
image relative to the top left corner of the image itself?

Andrew Poulos
 
T

Thomas 'PointedEars' Lahn

Andrew said:
I have a image in a scrollable DIV. The image is bigger than the display
size of the DIV. How do I get the coordinates of a mouse click on the
image relative to the top left corner of the image itself?

Handle the `click' event of the `img' element and subtract the image's
coordinates that are relative to the viewport's top left corner from the
pointer coordinates that are relative to the viewport's top left corner.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top