@mojule/dom-utils
TypeScript icon, indicating that this package has built-in type declarations

0.2.8 • Public • Published

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

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @mojule/dom-utils

Weekly Downloads

10

Version

0.2.8

License

MIT

Unpacked Size

179 kB

Total Files

25

Last publish

Collaborators

  • andybell
  • nrkn