"JS Advanced Program Design" of Eight

Source: Internet
Author: User
Tags shallow copy

1.

Node.element_node (1);  Element node Node.attribute_node (2);  Attribute node Node.text_node (3);   Text node

Each node has a ChildNodes property, which holds a NodeList object, accesses nodes in the nodelist, can be in square brackets, or it can use the item () method.

var firstchild = somenode.childnodes[0]; var secondchild = SomeNode.childNodes.item (1);

2. You can use the PreviousSibling and NextSibling properties to access the sibling elements. which

  

Somenode.firstnode = somenode.childnodes[0= somenode.childnodes[somenode.childnodes.length-1];

3. Node properties: Ownerdocument, which points to the document node that represents the entire document.

4. Operation node: Add a node to the end of the list, appendchild (Newcode).

5, InsertBefore (), receives two parameters: the node to be inserted and the node to be referenced.

  

Somenode.insertnode (NewNode, OldNode);

ReplaceChild (), receives two parameters: the node to be inserted and the node to be replaced.

Somenode.replacechild (NewNode, OldNode);

6, RemoveChild (), the method receives a parameter, that is, the node to be removed.

  

Somenode.removechild (Somenode.firstchild);

7, CloneNode (), used to create an identical copy of the node that called the method, to accept a Boolean parameter indicating whether to perform a deep copy, in case the parameter is true, to perform a deep copy, that is, the copy node and the entire child node tree, in case the parameter is false, perform a shallow copy , which is to replicate only the node itself.

8, normalize (), the only function is to process the text node in the document tree. If an empty text node is found, it is deleted and merged into a text node if an adjacent text node is found.

9, cross-domain security restrictions: from different subdomains of the page can not be through the JS communication, each page of the document.domain set to the same value, these pages will be able to access each other's JS object contained.

"JS Advanced Program Design" of Eight

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.