node

classfication

  1. element node
  2. attribute node
  3. text node

find

  • find parent node

    <DOM>.parentNode
  • find child node

    1. single

      <DOM>.childNodes

      get all child node include text node

    2. children

      <DOM>.children

      only get element node,return pseudo array

  • find brother node

    • next node

      <DOM>.nextElementSibling
    • previous node

      previousElementSibling

create node

  1. create

    document.createElement('<tag>')
  2. add

    • append

      next

      <fater Element>.appendChild(<create Element>)
    • insert

      before

      <fater Element>.insertBefore(<create Element>,<insert Element>)

clone

<Element>.cloneNode(<bool>)

CloneNode will clone the same elements as the original label

  • if true,it will clone descendant nodes
  • default is false

delet

<father Element>.removeChild(<delete Element>)

if there is no parent element,it cannot be deleted