JQuery Document fragment Processing

Source: Internet
Author: User

Through the JS Operation DOM node may be in the node units, such as the addition of nodes, you can createelement,createtextnode, and then use AppendChild to bind the text node and the container node together, It is then added to the DOM tree with AppendChild or insertbefor. But if you want to add a large number of nodes to the DOM tree dynamically. It will be very troublesome. And each time the DOM is refreshed, causing a performance flaw.

The workaround is to use the document fragment method to create the document fragment.

I personally think it would be appropriate to translate this into a document fragment.

Use the jquery solution.

<span style= "FONT-FAMILY:FANGSONG_GB2312;FONT-SIZE:18PX;" >

You can also use the following method to resolve

<span style= "FONT-FAMILY:FANGSONG_GB2312;FONT-SIZE:18PX;" >

The effect is the same.

Of course, you can also build a new node, such as a Div, to add op to the Div first, and then add the div to the body. But this will add a <div></div> to the body. However, document fragmentation does not produce such nodes.
Note: The binding fragment is actually attaching the contents of the fragment underneath the bound node. It does not produce nodes like <fragment></fragement>;


Best Wishes.


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.