Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

create parent div javascript

// `element` is the element you want to wrap
var parent = element.parentNode;
var wrapper = document.createElement('div');

// set the wrapper as child (instead of the element)
parent.replaceChild(wrapper, element);
// set element as child of wrapper
wrapper.appendChild(element);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #parent #div #javascript
ADD COMMENT
Topic
Name
4+6 =