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 Adobe 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 Adobe 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.

getElementsByTagName(tagName)

A NodeList that can be used to step through child 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, which the HTML 4.01 specification requires, or the length of the array that this function returns is incorrect.)

hasChildNodes()

A Boolean value that indicates whether the tag has any children.

hasTranslatedAttributes()

A Boolean value that indicates whether the tag has any translated attributes. (This property is not included in DOM Level 1; it was added to Adobe Dreamweaver 3 to support attribute translation.)