GetElementById

GetElementById is a method of the <code>Document</code> object in the Document Object Model. It is commonly used in JavaScript programming to refer to an HTML element for processing. Specifically, it returns a reference to an object that represents an element on the page, in the case of an HTML document, or a node, in the case of an XML document. The element can then be examined or manipulated through this object.
Examples
<source lang="HTML5">
<input type="text" size="10" name="phone_number" id="phone_number" />
<script type="text/javascript">
var phone = document.getElementById('phone_number');
</script>
</source>
If there is no element with the given ID, it returns null. The behavior of <code>getElementById</code> is undefined if more than one element has this ID, although in practice some web browsers return the first element with the given ID.
 
< Prev   Next >