English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery 'event.timeStamp' attribute

jQuery Events

The 'event.timeStamp' property returns the number of milliseconds from the first mouse left button down to the last lift.

By obtaining the event.timeStamp value at two points in the code and noting the difference, this property is very useful for analyzing event performance.

Syntax:

event.timeStamp

Example

Return the milliseconds consumed from the first mouse left button down to the last mouse up:

$("button").click(function(event) {
  $("span").text(event.timeStamp);
});
Test and See‹/›

Display the time since the last execution of the click handler:

$("document").ready(function() {
  let last, diff;
  $("button").click(function(event) {
if (last) {
   diff = event.timeStamp - last;
   $("p").text("Milliseconds since the last activity: " + last); + diff);
}
   $("p").text("Click the button again.");
}
  last = event.timeStamp;
  });
});
Test and See‹/›

Parameter Values

ParametersDescription
eventeventParameters from Event Binding Feature

jQuery Events