I have this small HTML file that when I enter a number in the input field, its onkeyup attribute triggers a button
Link here: https://www.w3schools.com/code/tryit.asp?filename=G8P7G9W1MFF4
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type=number min="1" max="5" value="1" class="example" name=text onKeyUp=myFunction();>
<button id="myBtn" onclick="javascript:alert('Hello World!')">Try it</button>
<script>
function myFunction() {
var x = document.getElementsByClassName("example");
if (x[0].value > 0) {
document.getElementById("myBtn").click();
}
}
</script>
</body>
</html>
The function triggers correctly when I type into the input field, but I want to know why the arrows don't trigger the function also.