When changing a html element with a function using innerHTML, the html element changes, but immediately the page reloads and the element is set back to his original value.
How can this be avoided ?
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<p id="test"> This should be changed after button click </p>
document.getElementById("test").innerHTML = "replaced";
type="button" in the
<button type="button" onclick="test()">Refresh</button>
By default, the type of the button is considered as
submit, thus submits the form on clicking the button.