Javascript examples for DOM:Document getElementsByTagName
Document getElementsByTagName() Method - Find out how many <li> elements there are 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 . j av a2 s . c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementsByTagName("LI"); document.getElementById("demo").innerHTML = x.length; } </script> </body> </html>