JS implementation of the child node of the DOM node insertion operation with the brothers node insertion operation example

The instance of this article describes the JS to implement the child node of the DOM node insertion operation with the brothers node insertion operation. Share to everyone for reference, specifically:

    www.jb51.net JS node Insert   Function showinsert () {// Add sub-node var str = document.getlementByid ("mydiv"); var zif = "paragraph 5"; var obj = document.createElement ("p"); // Add which class node var objNode = document.createTextNode (zif); // Create a text node str.appendChild (obj); obj.appendChild (objNode);} function showesideinsert () {// add sibling var str = document.getElementById ( " "); var zi =" Add Paragraph "; var strbrother = str.children [1]; var strnode = document.createElement (" p "); var strsXTNode = Document.createTextNode (zi); str.insertbefore (Strnode, strbrother; strnode.appendchild (strnode.Appendchild (strnodeNode);}      paragraph1  paragraph 
paragraph four

Using

online HTML / CSS / JavaScript Code Run Tool : http: //tools.jb51.net/code/htmljsrun test operation The effect is as follows:
More about JavaScript related content interested readers You can view this site: “JavaScript operation DOM skill summary”, “JavaScript error and debugging skill summary”, “JavaScript Data Structure and Algorithm Skill Summary”, “JavaScript Overclony Algorithm and Skill Summary” and “Summary of JavaScript Mathematical Computing]

I hope this article will help you JavaScript programming.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment