Change the textual content of a <p> element with id="myP"
:
document.getElementById("demo").textContent = "Paragraph changed!";
<!DOCTYPE html> <html> <body> <p id="demo" onclick="myFunction()">Click me to change my textual content.</p> <script> function myFunction() {// w w w . j a va 2s. c o m document.getElementById("demo").textContent = "Paragraph changed!"; } </script> </body> </html>