Wrap an element around a given element

Wrap the wrapper element around the ele element:

// First, insert `wrapper` before `ele` in its parent node
ele.parentNode.insertBefore(wrapper, ele);

// And then, turn `ele` into a children of `wrapper`
wrapper.appendChild(ele);

More

Previous
Upload files with ajax
Next
Select an element or list of elements