![]() |
mail us
|
mail this page products | company | support | downloads | isp services | contact us |
W3C Core Reference. Part of the Document Interface.
One of the three basic methods of getting a reference to a node using the DOM. Gets a reference to a node (always an element) which has an 'id="id-name"' attribute in its HTML definition (or more correctly has its id property set to 'id-name'.
element = document.getElementById(id-name)
| Name | Descriptiono | Notes |
| id-name | defined by 'id=id-name' in the HTML or has been assigned an id attribute of 'id-name'. |
// create some text
sometext = document.createTextNode("what a way to spend a life");
// stick them onto an existing object
existingobject = document.getElementById("one");
existingobject.appendChild(sometext);
// empty HTML paragraph fragment
<p id='one'></>
// example using id attribute
// create a new paragraph element
newnode = document.createElement("p");
newnode.id = "newnode";
// a long time later
node = document.getElementById("newnode");
// do something with the node
The first example uses an existing HTML id attribute to get the reference to 'one' the second example sets the 'id' attribute by code and then uses this id to obtain a reference later.
.
Problems, comments, suggestions, corrections (including broken links) or something to add? Please take the time from a busy life to 'mail us' (at top of screen), the webmaster (below) or info-support at zytrax. You will have a warm inner glow for the rest of the day.
tech home
audio stuff
web stuff
dom stuff
css stuff
language stuff
regex stuff
rfc stuff
protocol stuff
cable stuff
lan wiring
rs232 wiring
howto stuff
survival stuff
wireless stuff
ascii codes
data rate stuff
telephony stuff
mechanical stuff
pc stuff
electronic stuff
tech links
open guides
RSS Feed
If you are happy it's OK - but your browser is giving a less than optimal experience on our site. You could, at no charge, upgrade to a W3C STANDARDS COMPLIANT browser such as Mozilla
W3C HTML 4.01
HTML5 (WHATWG)
HTML4 vs HTML5
HTML5 Reference
W3C Page Validator
W3C DOCTYPE
W3C DOM
W3C DOM Events
Gecko DOM
MSIE DOM
usability.gov
W3C -WAI
Web Style Guide
Michael L Bernard
WebAim.org
Peter-Paul Koch
A List Apart
Eric Meyer on CSS
glish.com
DOCTYPE definitions
Our DOM Pages
DOM User Guide
DOM Explorer
DOM Navigation
CSS Short Cuts
CSS Techniques
CSS overview
Oh Really!
webmasterbase.com
Brainjar Menubar
Our Lite JS Menus
Our CSS Menus
Tigra Menus
|
Copyright © 1994 - 2010 ZyTrax, Inc. All rights reserved. Legal and Privacy |
site by zytrax![]() |
web-master at zytrax Page modified: May 24 2007. |