dom--Create node and node properties with internal insert append () and Appendto ()

Source: Internet
Author: User

Create node and node properties with internal insert append () and Appendto ()

1 Creating a process

creating nodes (common elements, attributes, and text)

Add some properties of a node

Adding to the document

2 methods involved in the process

Creating an element document,creat

Set Property Setattrilbute

Add text innerHTML

Add to document AppendChild

3 When creating a node note: Each element node must be created separately, the node is the attribute needs to be set separately, and the interface set is not very uniform, add to the specified element location is not flexible, browser compatibility problem processing

4 Creating ELEMENT nodes it is common to directly describe the structure of this node through an HTML tag string, which is handled by the $ () function ("HTML structure") such as $ ("<div><div>")

5 Create as this node similar to creating element nodes, you can directly describe the text content, such as $ ("<div> I am a text node </div>")

6 Create the same way as the attribute node as the element node is created, such as $ ("<div id= ' test ' class= ' Aaron ' > I am a text node </div>")

7 Append this operation is similar to the case where the native AppendChild method is performed on the specified element, adding them to the document

8 Appendto Use this method to reverse the normal $ (A). Append (b) operation, not to append B to a, but to append a to B

9 append () and Appendto () methods of operation

Append (content) appends contents to each matching element

AppendTo (content) appends all matching elements to another specified set of elements

Append () and. AppendTo () are functionally identical, the main difference being the location of the syntax, content, and target

append () front is the inserted object, followed by the content of the element to be inserted in the inward

AppendTo () is preceded by the element content to be inserted, followed by the inserted object

append () and. AppendTo () All insert the specified content at the end of the selected element (still inside)

dom--Create node and node properties with internal insert append () and Appendto ()

Related Article

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.