Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 0.73 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. GetElementsByTagName(tag).length
  2. var ul = document.getElementById('listing');
  3. function countLi(){
  4.     alert("There are "+ul.getElementsByTagName('li').length+" Li-Elements in this Documnet!");
  5. }
  6.        
  7. <input type="button" onclick="countLi()" value="Count the Li's!"/>
  8. <ul id="listing">
  9.     <li>one</li>
  10.     <li>two</li>
  11.     <li>three</li>
  12. </ul>​
  13.        
  14. var ul = document.getElementById('listing');
  15.        
  16. function countLi(){
  17.     var ul = document.getElementById('listing');
  18.     alert("There are "+ul.getElementsByTagName('li').length+" Li-Elements in this Documnet!");
  19. }
  20.        
  21. function countLi(){
  22.     var ul = document.getElementById('listing');
  23.     alert("There are "+ul.getElementsByTagName('li').length+" Li-Elements in this Documnet!");
  24.     }