Specifications
The Dreamweaver Document Object Model 45
Properties and methods of HTML tag objects
Every HTML tag is represented by a JavaScript object. Tags are organized in a tree hierarchy,
where tag
x is a parent of tag y, if y falls completely within x’s opening and closing tags (<x>x
content <y>y content</y> more x content.</x>
). For this reason, your code should be
well-formed.
The following table lists the properties and methods of tag objects in Dreamweaver, along with
their return values or explanations. A bullet (•) marks read-only properties.
getElementsByTagName(tagName) A NodeList that can be used to step through tags of type tagName (for
example, IMG, DIV, and so on).
If the tag argument is LAYER, the function returns all LAYER and ILAYER
tags and all absolutely positioned DIV and SPAN tags.
If the tag argument is INPUT, the function returns all form elements. (If a
name attribute is specified for one or more tagName objects, it must begin
with a letter as required by the HTML 4.01 specification, or the length of
the array that this function returns is incorrect.)
hasChildNodes() true
Property or method Return value
nodeType • Node.ELEMENT_NODE
parentNode • The parent tag. If this is the HTML tag, the document object returns.
childNodes • A NodeList that contains all the immediate children of the tag.
tagName • The HTML name for the tag, such as IMG, A, or BLINK. This value
always returns in uppercase letters.
attrName A string that contains the value of the specified tag attribute.
tag.attrName cannot be used if attrName is a reserved word in the
JavaScript language (for example, class). In this case, use
getAttribute() and setAttribute().
innerHTML The source code that is contained between the beginning tag and the
end tag.For example, in the code <p><b>Hello</b>, World!</p>,
p.innerHTML returns <b>Hello</b>, World!. If you write to this
property, the DOM tree immediately updates to reflect the new
structure of the document. (This property is not included in DOM
Level 1; however, it is supported by Internet Explorer 4.0.)
outerHTML The source code for this tag, including the tag. For the previous
example code, p.outerHTML returns <p><b>Hello</b>, World!</
p>. If you write to this property, the DOM tree immediately updates to
reflect the new structure of the document. (This property is not
included in DOM Level 1; however, it is supported by Internet Explorer
4.0.)
getAttribute(attrName) The value of the specified attribute if it is explicitly specified; otherwise,
null.
getTranslatedAttribute(attrName) The translated value of the specified attribute, or the same value that
getAttribute() returns if the attribute’s value is not translated. (This
property is not included in DOM Level 1; it was added to Dreamweaver
3 to support attribute translation.)
setAttribute(attrName, attrValue) Does not return a value. Sets the specified attribute to the specified
value: for example, img.setAttribute("src", "image/
roses.gif").
Property or method Return value