I have a square image/graph on which the user clicks.
Is there a way to display the (x,y) coordinates of the cursor to the user in real-time whenever the user hovers over the image (user does not need to click on the image)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here you go:
HTML:
JavaScript:
Live demo: http://jsfiddle.net/pSVXz/12/
With my updated code, you can have multiple images with this functionality – just add the class
"coords"to the images.Note: This code has to be inside the
loadhandler (instead of theready) handler, because we have to read the image’s dimensions which we can only do for fully loaded images.