My index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="test-1">
<img id="test" src="thumb1.png" width="15%" onmouseover="over(this)"
onmouseout="out(this)">
</div>
<script>
function over(x) {
document.getElementById('test').setAttribute('src','thumb.webp');
document.getElementById('test').setAttribute('width','15%');
var Delay;
Delay = setTimeout(thumb2, 4000);
}
function out(x) {
document.getElementById('test').setAttribute('src','thumb1.png');
}
function thumb2(){
document.getElementById('test').setAttribute('src','thumb2.png');
}
</script>
</body>
</html>
Hi, I already did some searches, but nothing satisfactory to fix the problem..
I would like some solution for this:
The
onmouseoverevent is executed, and 1 second later, theonmouseoutevent is also called andsetTimethat was executed by theoverfunction continues to count, reproducing a visual bug.
Is there any way to break the setTimer called by onmouseover event, when the onmouseout event is called?