event.timeStamp
S2C Home « Objects « event.timeStamp
Event timeStamp property.
Description
The event.timeStamp
Event object property, contains the value of the DOM element, or descendant thereof, that initiated the event.
- Can be used to monitor event performance by comparing the difference of the
event.timeStamp
value at different points in the code. - To determine the current time inside an event handler, use the
Date.now()
class method instead.
Syntax
Signature | Description |
---|---|
event.timeStamp | The value of the difference in milliseconds between the creation of this event by the browser and UTC (January 1, 1970). |
Parameters
None.
Return
A Number
object.
event.timeStamp
ExampleTop
Contains the value of the difference in milliseconds between the creation of this event by the browser and UTC (January 1, 1970).
When we click the button below twice or more a message is output displaying the elapsed time in milliseconds since the last click.
$(function(){
var prev, elapsed;
$('#btn7').on('click', function(event) {
if ( prev ) {
elapsed = event.timeStamp - prev;
$('#div5').append('Elapsed time since last event: ' + elapsed + ' milliseconds.<br/ >');
}
prev = event.timeStamp;
});
});
div5. Some initial text.