How to increase the child element node or child text node before the first child of the current node

使用: ParentNode.prepend();

var parent = the document.body; 

// add an element child nodes 
var P = document.createElement ( 'P' ); 
parent.prepend (P); 

// add text child 
parent.prepend ( 'the Hello' ); 

// add a plurality of element children 
var P1 = document.createElement ( 'P' );
 var P2 = document.createElement ( 'P' ); 
parent.prepend (P1, P2); 

// add elements and text node child node 
var P document.createElement = ( 'P' ); 
parent.prepend ( 'the Hello', P);

 

note: 

1. The increase may be children nodes or text nodes element node;

2. The increase may be a plurality of child nodes;

Guess you like

Origin www.cnblogs.com/aisowe/p/11528888.html