Presentation is loading. Please wait.

Presentation is loading. Please wait.

Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”

Similar presentations


Presentation on theme: "Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”"— Presentation transcript:

1 Create Element, Remove Child

2 The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”

3 Dynamic HTML JavaScript can change all HTML elements dynamically Can change all the HTML attributes Can change all the CSS styles Can remover exiting HTML elements and attributes Can add new HTML elements and attributes Can react to all existing HTML events Can Create new HTML events

4 Node Object Element Node,, Document Node Node Text Node data

5 Node Object Some nodes of the tree are JavaScript objects corresponding to HTML elements.,, elements Element node Other nodes may contain text representing the content of an element. Text node There is a node representing the document. Document node

6 Properties of Node nodeType: Number representing the type of node(Element) nodeName: string providing a name of this Node Type. parentNode: reference to object that is this node’s parent. childNodes: reference to nodes that are this node’s child. previousSibling: previous sibling of this node. nextSibling: next sibling of this node. attributes: an array containing Attr instances representing this node’s attributes.

7 Node type ValueSymbolic ConstantNode Type 1Node.ELEMETN_NODEElement 2Node.ATTRIBUTE_NODEAttribute 3Node.TEXT_NODEText 8Node.COMMENT_NODEComment 9Node.DOCUMENT_NODEDocument 10Node.DOCUMENT_TYPE_NODEDocumentType

8 Document Node Document Node is the parent of the html Element node. Properties of the document object title, body, url, etc Methods of the document object createElement(string): given an element type name (such as div), returns an Element instance corresponding to that element type. createTextNode(string): return a Text instance containing the given string as its data value. getElementById(string). getElementsByTagName(string).

9 Element Node Element node represents HTML elements.,,, etc Important methods of Element nodes. getAttribute(String) setAttribute(String, String) removeAttribute(String) hasAttribute(String)

10 Text Node Instances of the text DOM object are used to represent character data. The primary property of Text node is data, which is the text represented by the Text node. One Element node may have several Text nodes that are siblings of a single Text node.


Download ppt "Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”"

Similar presentations


Ads by Google