Created
March 17, 2015 20:36
-
-
Save hkfoster/1cb6d6c9f3da1cb92293 to your computer and use it in GitHub Desktop.
Native JS node-wrapping function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wrapNodes( nodes, type ) { | |
for ( var index = 0; index < nodes.length; index++ ) { | |
var node = nodes[ index ], | |
wrapper = document.createElement( type ); | |
node.parentNode.insertBefore( wrapper, node ); | |
wrapper.appendChild( node ); | |
} | |
} | |
wrapNodes( document.querySelectorAll( 'pre' ), 'div' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment