I need a popup div that will appear right below the anchor that i clicked. Now, I want to determine the x and y coordinates onClick event of an anchor. What’s the best practice of doing it? What are the advisable event properties to use?
Share
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.
offsetX and offsetY are relative to the parent container, whereas pageX and pageY are relative to the document. Don’t confuse this with
.offset()and.position(), in which.offset()is relative to the document and.position()is relative to the parent container’s.offset().Something like this example should work (JQuery):
http://api.jquery.com/offset/
http://api.jquery.com/position/