change the innerhtml of an element code example
Example 1: change innerhtml
document.getElementById("p1").innerHTML = "New text!";
Example 2: change element text innerhtml keeping the elements or tags inside
document.getElementById("tagname").firstChild.data = text;
Example 3: how to change .innerhtml back
<div id="d"> old content </div>
<script>
// Element stored in a variable for easy access
var div = document.getElementById("div");
// Save the original content of the div
var old = div.innerHTML;
// Change the content of the div
div.innerHTML = "new content";
// Reset the original content of the div
div.innerHTML = old;
</script>