Using the "*" parameter.
Get all elements in the document:
var x = document.getElementsByTagName("*");
Click the button to display the innerHTML of the UL element whose index is 3.
<!DOCTYPE html> <html> <body> <p>An unordered list:</p> <ul> <li>CSS</li> <li>HTML</li> <li>Java</li> </ul>/*w w w .j ava 2 s.c o m*/ <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>