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 RĂ©ponse
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.