@mojule/dom-utils
v0.2.8
Published
DOM traversal/query/manipulation functions
Downloads
66
Readme
dom-utils
DOM traversal/query/manipulation functions
npm install @mojule/dom-utils
example
const utils = require( '@mojule/dom-utils' )
const { parse, stringify, wrap, walk } = utils
const html = '<div>Hello</div>'
const div = parse( document, html )
walk( div, current => {
if( current.nodeName === '#text' ){
const p = document.createElement( 'p' )
wrap( current, p )
}
})
// '<div><p>Hello</p></div>'
console.log( stringify( div ) )