Properties and methods define the programming interface of the HTML DOM.
In the DOM, HTML documents consist of a set of node objects. The nodes can be accessed with
The programming interface of the DOM is defined by standard properties and methods.
Properties are often referred to as something that is (i.e. the name of a node).
Methods are often referred to as something that is done (i.e. remove a node).
Some DOM properties:
Note: In the list above, x is a node object (HTML element).
Some DOM methods:
The easiest way to get or modify the content of an element is by using the innerHTML
innerHTML is not a part of the W3C DOM specification. However, it is supported by all major
The innerHTML property is useful for returning or replacing the content of HTML elements
(including <html> and <body>), it can also be used to view the source of a page that
was dynamically modified.
The Below code gets the innerHTML (text) from the <p> element with
In the example above, getElementById is a method, while innerHTML is a property.
We can also use the childNodes and nodeValue properties to get the content of an element.
The Below code gets the value of the <p> element with id="intro":
In the example above, getElementById is a method, while childNodes and nodeValue are
In this tutorial we will mostly use the innerHTML property. However, learning the method above is
useful for understanding the tree structure of the DOM and dealing with XML files.
Your Query was successfully sent!