I am having trouble using .innerHTML within a javascript function called by clicking a button. For a brief flickering second I can see that the function is called, and the text changed, but then the text reverts.
<html>
<head>
</head>
<body>
<form>
<input type=submit value=Change the Text onClick=change()>
</form>
<div id=ToBeChanged> Hello, World </div>
<script>
function change(){
document.getElementById(ToBeChanged).innerHTML = New Text;
};
</script>
</body>
</html>
Of course, if I just use the .innerHTML outside of a function, it changes the text without any problems and does not revert to the old text. Is there a way to use .innerHTML to change text from the the onClick function? Or is there another way I should be accomplishing this task?