Dom
Dom Document Object Model documents it is primarily used to manipulate and access the properties and methods of each tag (tag) of a Web page
First clear:
???? 1. Use each tag in the HTML as an object in the DOM
???? 2. What are the attributes of the tag, then the object has
HTML document It has a certain level of relationship
HTML documents have only one
1. DOM node tree
Parent node
Child nodes
Sibling nodes they have a parent node at the same time
Text node
?
2. Node type
Document node root node
Element node Elements node
Attribute Node Properties node
Text node literal node
?
3. Dom classification
The core DOM is primarily manipulating HTML and XHTML to provide some properties and methods
HTML DOM is primarily manipulating HTML to provide some properties and methods
XML DOM is primarily manipulating XML
CSS DOM is mainly about manipulating CSS
The event DOM is primarily a manipulation of events
?
4. Core DOM operations 1, Common properties
NodeName node Name
FirstChild first child node
LastChild Last child node
ParentNode parent Node
ChildNodes List of child nodes it's actually a collection.
?
2, the operation of the label properties
Get Properties
The object you want to get. GetAttribute ("Property name")
?
Setting properties
SetAttribute ("Property name", "Property value")
?
Delete Property
RemoveAttribute ("Property name")
?
3, the operation of the label
1. Create a node (element)
???? Grammar:
???????? Document.createelement ("label name")
The return value is an element object
?
2. Adding nodes (elements)
Grammar:
The parent object. AppendChild (Element Object)
?
3. Deleting nodes
???? Grammar:
???????? Parent object. RemoveChild (child element Object)
?
5. Operation of HTML Dom
Because the core DOM is too cumbersome to manipulate HTML documents, then there is the HTML DOM
?
Document.getelemetbyid ("id attribute value")
Description
???? Get an object by the property value of the ID
This method only has the document
Returns a Label object gets what tag is what tag object
?
?
Parent object. getelementsbytagname ("tag name")
Description
???? This method it gets to is a collection even if you get only one it's also a collection
???? It accesses the same object name as the array element [subscript]
???? This method is owned by each parent object
?
Js DOM Object