how to use document write to id in javascript code example Example: change innerhtml document.getElementById("p1").innerHTML = "New text!";