How to Change Input Value in JavaScript?
- Get the input with
document.getElementById()
ordocument.querySelector()
. - Append value to it with
=
.
document.getElementById('divId').value = "value";
Example:
<input id="myInput" type="text">
<script>
document.getElementById('myInput').value = "New value";
</script>
Output: