In the following example we use the timeStamp property. It indicates the time in which the event happens in milliseconds.
There is a square designed with css. We will calculate the time that the mouse pointer stays inside it.
- event.timeStamp(). This event property calculates the difference in milliseconds between the time the event was created and January 1, 1970.
- mouseenter(). When the mouse enters an element. Refers only to the element.
- mouseleave(). When the mouse leaves an element. Refers only to the element.