'Function returing null
I'm trying to get the value from an number input type but when i try to show the value it returns a null (ps: sorry I'm still a highschool student) HTML:
<label for="nummatch"><h2>Number of Match/es:</h2></label>
<input type="number" onkeyup="stop(this)" id="nummatch" name="number of matches" value="1" min="1" max="5">
<br>
<a href="../html/Game Page.html#vsComputer"><button onclick="number()"><h1>VS Computer</h1></button></a>
JavaScript
function number(){
var times = document.getElementById("nummatch").value;
return timesNum;
}
var time = number();
console.log(time)
the console.log returns a error "Uncaught TypeError: Cannot read properties of null (reading 'value')"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
