95/95

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);

Might be useful