Here is an example of how you could do it in Javascript.
<h1 id="mi-h1">
Texto definido desde HTML
</h1>
<div>
<input id="input" type="text">
<button id="button">
Cambiar texto
</button>
</div>
In my html I have a <h1>
tag with text defined from the html code. Which will be changed with the writing in the input
when you click on the button.
let h1 = document.getElementById('mi-h1');
let input = document.getElementById('input');
let button = document.getElementById('button');
button.onclick = () => {
let texto = input.value;
h1.innerHTML=texto;
}
I declare some variables referring to the html elements. Clicking on the button stores the writing in the input and puts it on the <h1>
tag.