0
Why doesn’t var x = input.value work sometimes?
I’ve tried using var x = document.getElementById(“input”).value; before and it didn’t really work. I never used it since then. I just used input.value instead of var x = input.value; I’ve tried using the the var x... method today, it didn’t work as expected. I don’t really have a specific code right now, but y doesn’t it work?
1 ответ
0
Try to console.log(input)
See to it that it is a valid DOM element you can use, e.g. it is not undefined, and you don't get an error message in console.
Run the test in window.onload event handler to ensure the element is rendered beforehand.