User Guide
72 Chapter 4: The Dreamweaver Document Object Model
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.
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 the attrName attribute 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 opening tag
and the closing 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, but Internet Explorer
4.0 supports it.)
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, but
Internet Explorer 4.0 supports it.)
getAttribute(attrName)
The value of the specified attribute if it is explicitly specified;
null otherwise.
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")
.
removeAttribute(attrName)
Does not return a value. Removes the specified attribute and
its value from the HTML for this tag.