HTML DOM Nodes

Source: Internet
Author: User

HTML DOM Nodes Introduction
The HTML DOM treats the HTML document as a node tree.
HTML DOM nodes is divided into: document node, element node, attribute node, text node, annotation node.

HTML DOM Nodes Hierarchy
The hierarchical relationship of the node tree is divided into: parent, child, sibling sibling.
HTML DOM Nodes method
An HTML DOM method is an action that can be performed on a node.
element Node
Querying ELEMENT nodes
 
               
              
  1. var element = document.getElementById(‘id‘);
 
               
              
  1. var elements = documnet.getElementsByName(‘name‘);
 
               
              
  1. var elements = document.getElementsByTagName(‘tagName‘);
New element node
 
               
              
  1. element.insertBefore();
 
               
              
  1. element.appentChild();
Delete Element node
 
               
              
  1. createElement();
 
               
              
  1. element.removeChild();
modifying ELEMENT nodes
 
               
              
  1. element.replaceChild();
attribute Node
Query properties node
 
              
             
  1. element .get attribute () ;
New Attribute node
 
              
             
  1. element createattribute
Modify the Properties node
 
              
             
  1. element setattribute
text nodes:
New text node
     
              
             
  1. element.createTextNode();

HTML DOM Nodes Properties
The HTML DOM attribute is the value that we can set on the node to modify.
nodeGeneralProperties:
NodeName (name of the node)

NodeValue (Value of the node)

NodeType (Type of node)

node-level properties
Parent node
     
              
             
  1. node.parentNode;

Child nodes
     
              
             
  1. node.childNodes;
Brother Node
     
              
             
  1. node.nextSibling;






Null

HTML DOM Nodes

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.