Count the number of milliseconds between the two click events on a paragraph using jquery
- جي كويري
- 2021-09-22
- mhanasmh00489829403
الأجوبة
HTML Code :
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>Count the number of milliseconds between the two click events on a paragraph</title>
</head>
<body>
<p>Count the number of milliseconds between the two click events on a paragraph </p>
<div>Click on the above paragraph</div>
</body>
</html>
JavaScript Code :
var lastt, tdiff;
$( "p" ).click(function( event ) { if (lastt) {
tdiff = event.timeStamp - lastt;
$( "div" ).append( "Time since last event: " + tdiff + "<br>" );
}
else {
$( "div" ).append( "<br>Click again.<br>" );
}
lastt = event.timeStamp;
});
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة