xxxxxxxxxx
<!DOCTYPE html>
<html>
<body>
Name: <input type="text" id="myText" value="Mickey">
<p>Click the button to change the value of the text field.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("myText").value = "Johnny Bravo";
}
</script>
</body>
</html>
xxxxxxxxxx
// to get value from text input (or textarea):
// in html:
<input class="my-class">type something here with console opened</input>
// in js:
const myInputArea = document.querySelector(".my-class")
myInputArea.addEventListener("input", (e)=>{
const myInputText = e.target.value
console.log(myInputText)
})