+ 1
how to make a function so that it can read the contents of the input?
2 odpowiedzi
+ 4
you can read the value of input by first selecting that which input do you wanna read the value of,
let myInput = document.getElementById("myInput")
console.log(myInput.value) // its value
You can add a keyup event listener to that input so that you can get the value of input on every keystroke,
myInput.addEventListener("keyup", (e) => {
})
in this function you automatically get (e) which is the event, and the target of this event is myInput, so e.target would be the same as myInput, and you can get the value from both, myInput.value and e.target.value
+ 1
Thanks