JS Basic Knowledge Summary (4)

Source: Internet
Author: User

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
    1. 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
    2. 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
    3. 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
    4. Element . lastchild | | element . LastChild
    5. Element . nextSibling | | element . nextelementsibling
    6. Element . previoussibling | | element . previouselementsibling
    7. element. parentnode : read-only property The parent node of the current node
    8. 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
    9. < 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
    10. Style.width content : Style width
    11. ClientWidth : Width of Style +padding viewable area
    12. Offsetwidth : placeholder width style width + padding + border

JS Basic Knowledge Summary (4)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.