Appending a node after a JavaScript div element

Source: Internet
Author: User

Example Explanation:

This code creates a new <p> element:

var para=document.createelement ("P");

To add text to the <p> element, you must first create a text node. This piece of code creates a text node:

var Node=document.createtextnode ("This is the new paragraph. ");

Then you must append the text node to the <p> element:

Para.appendchild (node);

Finally, you must append this new element to an existing element.

This code finds an existing element:

var Element=document.getelementbyid ("Div1");

This code appends a new element to the existing element:

Element.appendchild (para);

var doc=document.createelement ("div"); Create P Element
Doc.innerhtml= ' <input name= "text1[]" onblur= "TJ ()" type= "text"/> <input name= "text" Name= "text2[]" type= " Text "/> <input name=" text "Name=" text3[] "type=" text "/>";//Create Text node
var Objdiv=document.getelementbyid ("D"); Objdiv.appendchild (doc);//Add elements to the specified div! You can test it!

Appending a node after a JavaScript div element

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.