Methods are actions that we can perform on a node (HTML element).
Programming interface
The HTML DOM can be accessed through JavaScript (and other programming languages).
All HTML elements are defined as objects, while programming interfaces are object methods and object properties.
Methods are actions that you can perform (such as adding or modifying elements).
A property is a value that you can get or set (such as the name or content of a node).
getElementById () method
The getElementById () method returns the element with the specified ID:
Example
<!DOCTYPE HTML><HTML><Body><PID= "Intro">Hello world!</P><P>This example demonstrates<b>getElementById</b>Method!</P><Script>x=document.getElementById ("Intro");d Ocument.write ("<p> Text from the intro paragraph:" +x.innerhtml+ "</p>");</Script></Body></HTML>
View results:
Hello world!
This example demonstrates the getElementById Method!
Text from the intro paragraph: Hello world!
HTML DOM objects-Methods and properties
Some common HTML DOM methods:
- getElementById (ID)-Gets the node (element) with the specified ID
- AppendChild (node)-Insert a new child node (element)
- RemoveChild (node)-Delete child nodes (elements)
Some common HTML DOM properties:
- InnerHTML-Text value of the node (element)
- ParentNode-parent node of the node (element)
- ChildNodes-Child nodes of nodes (elements)
- Attributes-node (element) attribute node
Some DOM object methods
HTML DOM Methods