QuizNot attempted
clientX vs pageX vs offsetX
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
pageX/pageY(document-relative, includes scroll)
- An absolutely positioned tooltip is placed in document coordinates, so you need the scroll offset included:
pageX = clientX + scrollX. - Not clientX/Y: viewport-relative, so on a scrolled page the tooltip lands too high (it is right for
position: fixed). - Not offsetX/Y: relative to whichever child element was hit, so it jumps around.
- Not screenX/Y: relative to the physical monitor, unrelated to the page.