How do I make an interval happen whenever I put a cursor on a button, and when your mouse gets out of the button, it clears the interval in JS / HTML?
Here is my code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function mouseOn() {
function int() {
document.getElementById("hover").click();
}
var interval = setInterval(int, 0);
}
function mouseOff() { clearInterval(interval); }
</script>
</head>
<body>
<button id="hover"
onmouseenter="mouseOn();"
onmouseleave="mouseOff();">
Hover and Autoclick
</button>
</body>
</html>
It doesn't autoclick when my mouse hovers on it. Do you guys know how to fix this?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/KFMx9E7
Comments
Post a Comment