I'm building this very simple app that changes the innerHTML of an H1 based on what you wrote in the text input.
But when I submit, the page loads and the text the person typed only stays in the page for a fraction of a second.
I'm sure this is a newbie issue, but I'd like to know what I should do different to keep the new text in the H1 even after the submit is clicked.
HTML:
<body>
<h1 id="numberOutput">Type something</h1>
<form onsubmit="changeNumber()">
<input type="text" name="numberInput" id="numberInput" value="Digite um número">
<input type="submit" name="">
</form>
</body>
JS
function changeNumber(){
//Sets var "text_input" to input value
text_input = document.getElementById("numberInput").value;
//Sets H1's innerHTML to be whatever the user typed
document.getElementById("numberOutput").innerHTML = text_input;
}
var text_input;