Referencing Document Elements Utilizing the W3C Document Object Model (DOM)

Available online: http://pointedears.de.vu/scripts/dom.htm
Copyright © 2002 @ Thomas 'PointedEars' Lahn. All rights reserved.

Source Code

[...]
<a href="..." ...> ... </a>
[...]
<a href="..." ...> ... </a>
[...]
<script type="text/javascript">
  function showType() {
    alert(typeof document.getElementById("hello1"));
    alert(typeof document.getElementsByName("hello2"));
    alert(typeof document.getElementsByTagName("a"));
    alert(document.getElementById("hello1").firstChild.nodeValue);
    alert(document.getElementsByName("hello2")[0].firstChild.nodeValue);
    alert(document.getElementsByTagName("a")[2].firstChild.nodeValue);
  }
</script>
<p><a href="#" id="hello1" name="hello2" onclick="showType(); return false;">Click Me!</a></p>
    

Example

(requires JavaScript)

Click Me!