September 2024
Beginner to intermediate
985 pages
35h 37m
English
Elements, too, can be created manually via methods and then added to the DOM tree (as opposed to using the innerHTML property, where you pass the HTML elements indirectly in the form of the text you assign to the property).
In this section, we’ll show you how to create and add elements using these methods and how to work with elements in general.
To create elements, use the createElement() method. This method expects the name of the element to be created as a parameter and returns the new element. By calling the method, the new element is not yet added to the DOM, though (same as with text nodes when using the createTextNode() method).
However, several other methods are available ...
Read now
Unlock full access