Javascript examples for DOM:Document getElementsByTagName
The following code shows how to Get all elements in the document:
<!DOCTYPE html> <html> <body> <p>An unordered list:</p> <ul> <li>A</li> <li>B</li> <li>C</li> </ul>// w w w.java 2 s .com <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementsByTagName("*"); document.getElementById("demo").innerHTML = x[3].innerHTML; } </script> </body> </html>