JS Supplements: AppendChild Add mobile Node

Source: Internet
Author: User

Original: JS Supplements: AppendChild Add mobile Node

Write JS for more than a year, has been thinking that they are very good, began to write a variety of blog posts to share, yesterday wrote a "talk about IE under the innerhtml caused problems" in the following comments, I found how ignorant.
So I went back to the next mdn,node.appendchild, which was made clear from the beginning,"If the node already exists, it is removed from the current parent node and then added to the new parent node." "
The simple point is to move the current node meaning, so yesterday's code to remove obox.innerhtml = ""; can be fully compatible.

Take a look at a common example:

var p = document.createelement ("P");d Ocument.body.appendChild (p);

This is the most common usage, creating a P-node that is added to the end of the body.

var p1 = document.getElementById ("p1");d Ocument.body.appendChild (p1);

The meaning of this code is to select the node with ID p1 and move to the end of the body.

Simply put, the node is placed at the end of the specified parent node, either new or selected.

However, InnerHTML in IE, there are real bugs, but I did not find the relevant article, I hope there will be a chance to solve the problem.

Through this question let me realize how ignorant I am, indeed should stop step, turn back supplements.

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.