Deep Learning JS Node

Source: Internet
Author: User
Tags tag name

Deep Learning JS Node

DOM (model)

All the nodes in the HTML document make up a document tree model,

Every element, attribute, text, and so on in an HTML document represents a tree

A node. These nodes are interconnected and affect each other to form a

The complete page we call the model.

Each component in an HTML document is a node.

? The entire document is a document node

? Each HTML tag is an element node

? Text that is contained in an HTML element is a text node

? Each HTML attribute is an attribute node

? Comments belong to note nodes

Properties of the Node

What can I do with node properties?

1. Through the properties of the node, the relationship between each node can be obtained, and through this relationship,

Get an exact and fast object to the corresponding node.

Get the properties of a node relationship

Object. parentnode get a reference to the parent node

Object. ChildNodes gets the collection of child nodes

Object. FirstChild get a reference to the first child node

Object. LastChild get a reference to the last child node

Object. nextSibling get a reference to the next sibling node

Object. PreviousSibling get a reference to the previous sibling node

Method of Node

Our previous operations on the page elements are in the operation of existing elements,

So how do we dynamically create, delete, change, copy elements, and give

element to add attributes, styles? Then we need to use the method of our node.

Method of Node

First, create a node

1> Creating ELEMENT nodes

Document.createelement ("element tag name");

2> Creating an attribute node

Object. SetAttribute (property name, property value)

3> Creating a text node

object. innerhtml= "";

document.createTextNode ("text");

Method of Node

Second, append to the page

The parent object. AppendChild (Append object)

Adds a node after the last child node of the specified element node

The parent object. InsertBefore (The object to insert, the previous object) is inserted

Before you go to an object

Method of Node

? Third, delete the node

? The parent object. RemoveChild (Deleted objects)

? If you decide to delete a node, it is best to also empty the memory object =null;

Method of Node

Third, modify (replace) the node

The parent object. ReplaceChild (new node, modified node);

Iv. Replication Nodes

The node to replicate. The CloneNode () method creates a copy of the specified node.

The method has one parameter (TRUE or FALSE). If set to True,

All child nodes will also be cloned, or only the node will be cloned

Deep Learning JS Node

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.