Presuming you already know that every page element is a node in a tree called the DOM, it's not hard to imagine there are several types of nodes: attributes of tags, tags, text nodes and so on...
a javascript property of objects let's you determine wich type a node is of, like this:
var nodetype = obj.nodeType;
| Returned integer | Node type Constant |
|---|---|
| 1 | ELEMENT_NODE |
| 2 | ATTRIBUTE_NODE |
| 3 | TEXT_NODE |
| 4 | CDATA_SECTION_NODE |
| 5 | ENTITY_REFERENCE_NODE |
| 6 | ENTITY_NODE |
| 7 | PROCESSING_INSTRUCTION_NODE |
| 8 | COMMENT_NODE |
| 9 | DOCUMENT_NODE |
| 10 | DOCUMENT_TYPE_NODE |
| 11 | DOCUMENT_FRAGMENT_NODE |
| 12 | NOTATION_NODE |
other properties are nodeName wich is supposed to return some human readable form but almost fails at it and nodeValue wich you can use to change node values
Comentarii