Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

prependchild javascript

//Newest method - only works in Opera, Chrome and Firefox 

let parent; //Some DOM Element 
let newChild; //Element wanting to append start of parent

parent.prepend(newChild); //Places newChild at start of parent.

//Alternatively, this can be used to add it to the end:

parent.append(newChild);

// parent.appendChild(newChild) can also be used, but you may only append one node, and 
// no strings. However, it does return the element being appended.

 
PREVIOUS NEXT
Tagged: #prependchild #javascript
ADD COMMENT
Topic
Name
6+6 =