Properties are values of nodes (HTML Elements) that you can get or set
The HTML DOM can be accessed with JavaScript (and other programming languages).
The programming interface of the DOM is defined by methods and properties.
A method is an action you can do (like add or delete a node).
A property is a value that you can get or set (like the name or content of a node).
The easiest way to get the content of an element is by using the innerHTML property.
The innerHTML property is useful for getting or replacing the content of HTML elements.
The following code gets the innerHTML from the <p> element with id="intro":
In the example above, getElementById is a method, while innerHTML is a property.
| The innerHTML property can be used to get or change any HTML elements, including <html> and <body>. |
The nodeName property specifies the name of a node.
Note: nodeName always contains the uppercase tag name of an HTML element.
The nodeValue property specifies the value of a node.
The following example retrieves the text node value of the <p id="intro"> tag:
The nodeType property returns the type of node. nodeType is read only.
The most important node types are:
| Element type | NodeType |
|---|---|
| Element | 1 |
| Attribute | 2 |
| Text | 3 |
| Comment | 8 |
| Document | 9 |
Your message has been sent to W3Schools.