The structure of a web page is represented as a tree of nodes in the DOM. A web page can start its life with an initial DOM tree, marked up in its HTML file, and the tree can be changed using the code; or it can start off with an empty tree, which is then entirely created using the code in the app: every element is created through a constructor and its properties are set in the code. Elements are subclasses of Node
; they take up a rectangular space on the web page (with a width and height). They have, at most, one parent element in which they are enclosed and can contain a list of elements—their children (you can check this with the hasChildNodes()
function that returns a bool
function). Furthermore, they can receive events. Elements must first be created before they can be added to the list of a parent element. Elements can also be removed from a node. When elements are added or removed, the DOM tree changes and the browser has to re-render the web page.
An...