The basic operation of the DOM

  1. check
    1. View element node
      1. document on behalf of the entire document
      2. document.getElementById () id element in the browser IE8, id not case sensitive, but also returns the name attribute matching elements
      3. .getElementsByTagName () // tag name
      4. .getElementsByName () // It should be noted that only part of the tag name may take effect (forms, form elements, img, iframe)
      5. .getElementsByClassName () // class name -> ie8 and below ie8 ie version does not, can together multiple class
      6. .querySelector () // css selector is not in ie7 ie7 and in the following versions
      7. .querySelectorAll () // css selector is not in ie7 ie7 and in the following versions
    2. Traverse the node tree
      1. parentNode -> parent node (for the topmost parentNode #document)
      2. childNodes -> child nodes are
      3. firstChild -> the first child
      4. lastChild -> the last child
      5. nextSiling -> after a sibling
      6. previousSiling -> previous sibling node
    3. Based traversing element node of the tree
      1. parentElement -> Returns the parent element of the current node element (IE incompatible)
      2. children -> only returns element children of the current element

Guess you like

Origin www.cnblogs.com/zhuzhu520/p/11929100.html