add html tag text attribute in javascript function code example Example: change text of element js document.getElementById("p1").innerHTML = "New text!";