developer sign in
where » create » reference » attributes » id

id


The id attribute identifies this element with a given name in the DOM tree.

Details

  • There are two ways to identify elements in the page: document.getNodeById(<elementId>) and document.<elementId> where <elementId> is the id attribute of an element.


  • document.getNodeById(<elementId>) searchs the DOM tree to find the first occurrence (highest order) of any element with id equal to <elementId>.


  • document.<elementId> is a "short cut" to identify Parent Elements directly under the jin element and Display Elements directly under a page row element. Given multiple elements with id equal to <elementId>, this identifies the last occurence (lowest order) of the element in the DOM tree.


  • document.<elementId> is the faster method to identify an element. It should be used in place of document.getNodeById(<elementId>) where possible.

Example

<script>
function findTheNode() {
  var node = document.getNodeById('testId');
  // this alerts "text" to the screen
  alert(node.value);

  var node2 = document.testId;
  // this alerts "Press Me" to the screen
  alert(node2.value);

}
</script>



<body>
  <pr>
    <text id="testId" value="text">Some text</text>
  </pr>
  <pr>
    <input type="button" value="Press Me" id="testId" onselect="findTheNode()" />
  </pr>
</body>

terms of use | privacy policy | about | FAQ | blog | jobs | contact us
For 24/7 support email support@where.com or call 888-262-1150
WHERE™ is a product from uLocate Communications, Inc. ©2007 All Rights Reserved.