event.timeStamp
event.timeStamp Returns: Number
Description: The difference in milliseconds between the time an event is triggered and January 1, 1970.
-
version added: 1.2.6event.timeStamp
This property can be useful for profiling the performance of certain jQuery functions by getting the event.timeStamp
value at two points in the code and noting the difference.
Example:
Display the time since the click handler last executed.
<!DOCTYPE html>
<html>
<head>
<style>
div { height: 100px; width: 300px; margin: 10px;
background-color: #ffd; overflow: auto; }
</style>
<script src="http://code.jquery.com/jquery-1.7rc2.js"></script>
</head>
<body>
<div>Click.</div>
<script>
var last, diff;
$('div').click(function(event) {
if ( last ) {
diff = event.timeStamp - last
$('div').append('time since last event: ' + diff + '<br/>');
} else {
$('div').append('Click again.<br/>');
}
last = event.timeStamp;
});
</script>
</body>
</html>