append-child
v1.0.0
Published
Append an HTML element to the DOM and return a removal function
Downloads
26
Maintainers
Readme
append-child
Append an HTML element to the DOM and return a removal function
Install
$ npm install --save append-child
Usage
var appendChild = require('append-child')
var element = document.createElement('div')
var remove = appendChild(element)
//=> div appended to body
remove()
//=> div removed from body
API
appendChild(element, [parent])
-> function
Returns a remove
function.
element
Required
Type: HTMLElement
A DOM element to insert.
parent
Type: HTMLElement
Default: document.body
The parent element to append to.
License
MIT © Ben Drucker