返回值:Numberevent.timeStamp
V1.2.6jQuery event.timeStamp概述
這個(gè)屬性返回事件觸發(fā)時(shí)距離1970年1月1日的毫秒數(shù)。
這可以很方便的檢測(cè)某個(gè)jQuery函數(shù)的性能。
示例
描述:
顯示兩次點(diǎn)擊之間的時(shí)間。
代碼:
<!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-latest.min.js"></script>
</head>
<body>
<div></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>