The createelement () method of the HTML DOM object

Source: Internet
Author: User

Today, when we learned about DOM node operations, we discovered an interesting phenomenon of the createelement () method for creating DOM nodes.

The code is as follows:

var Box=document.getelementbyid ("box");//Assume that there is already an element in the page with the ID box;

var Bbb=document.getelementbyid ("BBB");//Assume that there is already an element in the page with the ID box;

var aaa=document.createelement ("div");//Create a DIV element

Box.appendchild (AAA);//Insert a new node in the last face of the box element AAA; (at this point, AAA in the last Face of Box)

Box.insertbefore (AAA,BBB);//Insert a new node before the box element AAA; (at this point, AAA is in front of the BBB and disappears from the back of Box)

Box.appendchild (AAA);//Insert a new node in the last face of the box element AAA; (at this point, AAA is at the end of box and disappears from the front of box)

So I guess the elements created by the createelement () method are dynamic and unique,

No matter how many times you call an element that you create, the location of the element created by createelement () is determined by the node that was last called.

In this temporary record, we will leave it to further understanding.

The createelement () method of the HTML DOM object

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.