Manipulating the DOM
While we will be able to use haXe to target JavaScript and create a website, haXe doesn't really provide us with any abstraction layers over the DOM.
We will try to remember some things about the DOM and see how it is exposed by haXe.
The browser's DOM
The browser's DOM (Document Object Model) defines what objects the browser should expose to our application in order to represent the document (the HTML page) and to provide us with some functionality (think about the date object).
It is in the DOM that the type of each HTML object (such as a list, an item in a list, a header, and so on) is defined. In addition, in the DOM it is defined that, for example, an HTML node should have an appendChild
function in order to allow the addition of child nodes.
Let's remember some basics of the DOM manipulation in JavaScript.
Nodes
Everything in HTML is a node. There are several types of nodes, we won't list them all here, but what we need to remember is that there are two big ones when...