When I try to run this script, it updates my array for a second, but it seems that after the function runs, the document returns to normal.
What's the best way to solve this problem?
<p id="demo"></p>
<form>
<input type="submit" onclick="add_value()"/>
</form>
<script>
var array = ["1", "2", "3"];
document.getElementById("demo").innerHTML = array[3];
function add_value() {
array.push("69");
document.getElementById("demo").innerHTML = array[3];
document.getElementById("demo2").innerHTML = array[3];
}
</script>