I want to assign a variable to the html input. This is what I tried but it doesn't work.
<input type=number>let x = 10</input>
I want to assign a variable to the html input so that I can use it later, how can I do this.
P粉3021604362024-02-05 00:34:02
Get the input element in js and assign it a value like this
const input = document.querySelector("input"); let x = 10; input.value = x;