domy-insert
Insert any data type to the DOM. For use with Browserify.
Part of the Domy module collection.
Install
npm install domy-insert --save
Usage
var insert = require('domy-insert');
insert('<div class="item"></div>').after('.some-parent-element');
insert('<div class="before-item"></div>').before('.item');
var div = document.createElement('div');
div.className = 'another-element';
insert(div).beginning('.parent');
insert(div).end() // inserted at end of document.body
Methods
insert(element)
element- string OR DOM element to insert
Creates and returns an object with the following methods available:
beforeafterbeginnningend
Instance Methods
before(sibling[, parent])
sibling- string or object of element to insert beforeparent- string or DOM element of context of insert. Defaults todocument.body
after(sibling[, parent])
sibling- string or object of element to insert afterparent- string or DOM element of context of insert. Defaults todocument.body
beginning([parent])
Insert an element at the beginning of the given parent's child node list
parent- string or DOM element of context of insert. Defaults todocument.body
end([parent])
Works the same as insert(element, parent). Inserts element at the end of the given element context
parent- string or DOM element of context of insert. Defaults todocument.body
Run Tests
npm install
npm test
