Search code examples
javascriptjquerytimerjquery-eventsonmousemove

How to get the starting time of a mousemove event in Javascript/jQuery?


Is there any attribute associated with the starting time I can get from the 'event' parameter in the callback function of a mousemove event?


Solution

  • This code will store time (as timestamp) when mousemove happend first within a element:

     var startTime = null;
        $('<YOUR_ELEMENT>').one('mousemove', function(e) {
            startTime = e.timeStamp;
            console.log(startTime);
        });