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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top