Skip to content

Instantly share code, notes, and snippets.

@airton
Last active September 13, 2016 20:52
Show Gist options
  • Save airton/05c258d1fa50f208cb6a686f4db87117 to your computer and use it in GitHub Desktop.
Save airton/05c258d1fa50f208cb6a686f4db87117 to your computer and use it in GitHub Desktop.
// select element to unwrap
var el = document.querySelector('div');
// get the element's parent node
var parent = el.parentNode;
// move all children out of the element
while (el.firstChild) parent.insertBefore(el.firstChild, el);
// remove the empty element
parent.removeChild(el);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment