Returns a reference to the first object with the specified value of the ID attribute.
Syntax
oElement = document.getElementById(sIDValue)
Parameters
sIDValue Required. A String that specifies the value of an ID attribute.
Return Value
Returns the first object with the same ID attribute as the specified value.
Remarks
If the ID value belongs to a collection, the getElementById method returns the first object in the collection.
Example
This example uses the getElementById method to return the first occurrence of the ID attribute value, oDiv.
<SCRIPT> function fnGetId(){ // Returns the first DIV element in the collection. var oVDiv=document.getElementById("oDiv1"); } </SCRIPT> <DIV ID="oDiv1">Div #1</DIV> <DIV ID="oDiv2">Div #2</DIV> <DIV ID="oDiv3">Div #3</DIV> <INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">
Standards Information
This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Include the following to ensure getElementById is available even in a browser without native getElementById but with document.all (such as MSIE 4):
if (document.all && !document.getElementById) { document.getElementById = function(id) { return document.all[id] } }
See also:
file: /Techref/inet/iis/jscript/htm/getElementById.htm, 2KB, , updated: 2009/7/28 13:12, local time: 2024/11/29 22:32,
18.119.133.138:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/Techref/inet/iis/jscript/htm/getElementById.htm"> getElementById</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.