Document getElementsByTagName() Method - Using the "*" parameter. - Javascript DOM

Javascript examples for DOM:Document getElementsByTagName

Introduction

The following code shows how to Get all elements in the document:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials