Javascript - Track mouse position

后端 未结 11 1240
谎友^
谎友^ 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 03:51

    Just a simplified version of @T.J. Crowder and @RegarBoy's answers.

    Less is more in my opinion.

    Check out onmousemove event for more info about the event.

    There's a new value of posX and posY every time the mouse moves according to the horizontal and vertical coordinates.

    
        
        
          
          Example Mouse Tracker
          
        
        
        

    Mouse tracker

提交回复
热议问题