Javascript - Track mouse position

后端 未结 11 1640
谎友^
谎友^ 2020-11-22 03:13

I am hoping to track the position of the mouse cursor, periodically every t mseconds. So essentially, when a page loads - this tracker should start and for (say) every 100 m

11条回答
  •  佛祖请我去吃肉
    2020-11-22 04:09

    Irrespective of the browser, below lines worked for me to fetch correct mouse position.

    event.clientX - event.currentTarget.getBoundingClientRect().left event.clientY - event.currentTarget.getBoundingClientRect().top

提交回复
热议问题