kota's memex

The global variable document gives access to the Document Object Model. It's documentElement property points to an object representing the <html> tag. It also has a head and body property pointing at those elements.

Each DOM node has a nodeType property, which contains a number that identifies the type of the node. Elements have code 1, (Node.ELEMENT_NODE). Text nodes, representing a section in the document, get code 3 (Node.TEXT_NODE). Comments have code 8 (Node.COMMENT_NODE) and so on.

The DOM interface is clumbersome and cryptic. It was not designed for use with just javascript and doesn't mesh particuarly well with it. For example, the childNodes property holds an array-like object, with the length property and properties labeled by numbers to access the child nodes. But it is an instance of NodeList, not a real array, so it does not have methods such as slice and map.

moving through the tree