javaScript htmlDom nodes

the dom represents a document as a tree. the tree is made up of parent-child relationships, a parent can have one or many children nodes.

the node interface is the primary data type for the document object model(dom). it represents any single item in the tree, such as an element, attr, or entity.

note : the dom is that every node is an object.we can get a node and change its properties.

look a simple html document.

 <!doctype    html >
                    <title>the web page</title>
                  <div>msn news</div>
                 <div>html code</div>

look the dom if we represent it as a tree.

note : whitespce symbols in the html are recognized as the text and become text nodes. these whitespace nodes are not shown in developer tools, but they do exist.

the following table is an overview of each of the node interfaces.

node typetypedescriptionexample
1elementan html or xml element<p> .... </p>
2attributean attribute for an html or xml element<p class='body'>
3textrepresents the text content inside an element this is paragraph
4cdatasectionrepresents a cdata section in xml.[![cdata]]
5EntityReferencethe name of the entity referenceamp lt
6entitythe entity name &
8commentan html comment<!-- comment -->
9documentthe root document object<html>
10documentTypea document type definition<!doctype html>