Create HTML new Element (JS)

Source: Internet
Author: User

1 <!--2 create a new HTML element3 1. Create a new element4 2. Create a new node5 3. Append Nodes6 4. Append a new element to an existing element7  -8 <HTML>9 <Body>Ten  One <DivID= "Div1"> A <PID= "P1">This is a paragraph</P> - <PID= "P2">This is another paragraph</P> - </Div> the  - <Script> - varpara=Document.createelement ("P"); //Section1 Steps - varnode=document.createTextNode ("This is a new paragraph."); //Section2 Steps + para.appendchild (node);//Section3 Steps -  + varelement=document.getElementById ("Div1"); A Element.appendchild (para); //Section4 Steps at </Script> - </Body> - </HTML>

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.