Tag: Name insert parent node property for set nod description RTB
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 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
You'll learn more about attributes in the next chapter of this tutorial.
The object of real life
A person is an object.
The human method may be eat (), sleep (), work (), play (), and so on.
Everyone has these methods, but they are executed at different times.
A person's attributes include name, height, weight, age, gender, and so on.
Everyone has these attributes, but their values vary from person to person.
Some DOM object methods
Here are some common ways you'll learn in this tutorial:
method |
Description |
getElementById () | td> returns the element with the specified ID.
getelementsbytagname () |
Returns a list of nodes (a collection/node array) that contains all the elements with the specified label name. |
getelementsbyclassname () |
Returns a list of nodes that contain all the elements with the specified class name. |
appendchild () |
adds a new child node to the specified node. |
removechild () |
deletes child nodes. |
replacechild () |
replaces child nodes. |
insertbefore () |
inserts a new child node in front of the specified child node. |
createattribute () |
creates an attribute node. |
createelement () |
creates an element node. |
createtextnode () |
creates a text node. |
getattribute () |
returns the specified property value. |
setAttribute () |
Sets or modifies the specified property to the specified value. |
var Element=document.getelementbyid ("Intro");
HTML DOM Methods