Methods are actions you can perform on nodes (HTML Elements)
All HTML elements are defined as objects, and the programming interface is the object methods and object properties .
A method is an action you can do (like add or modify an element).
A property is a value that you can get or set (like the name or content of a node).
The getElementById() method returns the element with the specified ID:
Some commonly used HTML DOM methods:
Some commonly used HTML DOM properties:
You will learn more about properties in the next chapter of this tutorial.
A person is an object.
A person's methods could be eat(), sleep(), work(), play(), etc.
All persons have these methods, but they are performed at different times.
A person's properties include name, height, weight, age, eye color, etc.
All persons have these properties, but their values differ from person to person.
Here are some of the (most common) methods you will learn about in this tutorial:
|getElementById()||Returns the element that has an ID attribute with the a value|
|getElementsByTagName()||Returns a node list (collection/array of nodes) containing all elements with a specified tag name|
|getElementsByClassName()||Returns a node list containing all elements with a specified class|
|appendChild()||Adds a new child node to a specified node|
|removeChild()||Removes a child node|
|replaceChild()||Replaces a child node|
|insertBefore()||Inserts a new child node before a specified child node|
|createAttribute()||Creates an Attribute node|
|createElement()||Creates an Element node|
|createTextNode()||Creates a Text node|
|getAttribute()||Returns the specified attribute value|
|setAttribute()||Sets or changes the specified attribute, to the specified value|
Your message has been sent to W3Schools.