Dom
- Dom:document Object Model-Document object type
- Documents: HTML pages
- Document objects: Elements in a page
- Document Object Model: definition to enable the program (JS) to manipulate elements in the page
- The DOM considers the document as a tree, and defines many ways to manipulate each element (node) in the tree.
- DOM node operations
- ChildNodes
- element. ChildNodes : read-only attribute child node list collection
- Standard: Contains element nodes and text nodes, and also contains illegal nested child nodes
- Non-standard: does not contain text nodes IE7 The following does not contain illegal nested child nodes
- ChildNodes contains only one level of child nodes and does not contain nodes below the grandchild level of the descendants
- There are 12 types of DOM nodes
- element. NodeType : Read-only property Type property of the current element node
- ELEMENT node: 1
- Text nodes: 3
- Attribute node: 2
- element. Attributes: Read-only Property list collection
- Chlidren
- element. Children: read-only attribute child node List property collection
- Standard: Nodes that contain only element types
- Non-standard: nodes that contain only element types
- Element . firstchild | | element . firstelementchild
- Element . firstchild Read-only property The first child node
- Standard: Firstchild will contain nodes of type text
- Non-standard: contains only ELEMENT nodes
- Element . lastchild | | element . LastChild
- Element . nextSibling | | element . nextelementsibling
- Element . previoussibling | | element . previouselementsibling
- element. parentnode : read-only property The parent node of the current node
- offsetParent : The property is read-only to a location-nearest parent node that is closest to the current element
- body
- ie7 bodyhtml
- ie7 below if a parent of the current element has triggered a layuotoffersetparentlayout
- < Span lang= "en-US" >offsetleft[top]: read-only properties The current element to the location of the parent's distance (offset value) to the current element offsetparent
- If no parent is located:
- Standard: offsetParent ==> body; offsetleft ==> html
- If you have a location parent Level
- ie7: If you do not have a location, then offsetleft [TOP] body
- Standard: Distance to target parent
- Style.width content : Style width
- ClientWidth : Width of Style +padding viewable area
- Offsetwidth : placeholder width style width + padding + border
JS Basic Knowledge Summary (4)