Javascript examples for DOM:Document getElementsByTagName
Document getElementsByTagName() Method - Change the HTML content of the first <p> element (index 0) in the document:
<!DOCTYPE html> <html> <body> <p>This is also a paragraph.</p> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w w w . jav a 2 s. co m document.getElementsByTagName("P")[0].innerHTML = "Hello World!"; } </script> </body> </html>