Alert the HTML content of a <p> element with id="demo":
<!DOCTYPE html> <html> <body> <p id="demo">Click the button to alert the text of this paragraph.</p> <p id="demo1"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* w w w . j a va2 s .c om*/ document.getElementById("demo1").innerHTML = document.getElementById("demo").innerHTML; } </script> </body> </html>