JSFiddle - React, Tailwind, and code Playground
HTML
<div class="block1">Блок 1</div>
<div class="block2">Блок 2</div>
CSS
* {
margin: 0;
padding: 0;
}
html, body {
width: 100%;
height: 100%;
}
div {
width: 100px;
height: 100px;
position: absolute;
color: white;
text-align: center;
line-height: 100px;
}
.block1 {
top: 0;
left: 0;
background: red;
}
.block2 {
bottom: 0;
right: 0;
background: blue;
}
JavaScript
var block1 = document.querySelector(".block1");
var block2 = document.querySelector(".block2");
var startTime, endTime, result;
block1.onmouseout = function()
{
startTime = new Date();
};
block2.onclick = function()
{
endTime = new Date();
result = endTime - startTime;
alert(result + " миллисекунд");
};