dom node types · element · text · attribute · comment
Pixel PeteVSQuirks Mode
Pixel Pete saysThe DOM has node types: element, text, attribute, and comment nodes.
Not every node is an element. Element nodes are your tags; text nodes hold the characters between them (including whitespace!); comment nodes hold <!-- -->; attributes are nodes too. nodeType identifies which. This is why childNodes can surprise you with whitespace text nodes — prefer children for elements only.
Power-ups you unlock
Element, text, comment, attribute nodes
Whitespace becomes text nodes
nodeType identifies the kind
children = elements only; childNodes = all
Quirks Mode attacks — common mistakes
Expecting childNodes to be elements only
Tripping over whitespace text nodes
Ignoring nodeType when walking the tree
Boss battleCount an element’s childNodes vs children and explain the difference.