domy-insert

Insert any data type to the DOM. For use with Browserify.

Usage no npm install needed!

<script type="module">
  import domyInsert from 'https://cdn.skypack.dev/domy-insert';
</script>

README

domy-insert

Insert any data type to the DOM. For use with Browserify.

Part of the Domy module collection.

browser support

Install

npm install domy-insert --save

Usage

var insert = require('domy-insert');

insert('<div class="item"></div>');
insert.before('<div class="before-item"></div>', '.item');

var div = document.createElement('div');
div.className = 'another-element';

insert(div, '.parent');

Methods

insert(element[, parent])

  • element - string OR DOM element to insert
  • parent - string OR DOM element to insert the element to. Defaults to document.body

insert.before(element, sibling[, parent])

  • element - string OR DOM element to insert
  • sibling - string or object of element to insert before
  • parent - string or DOM element of context of insert. Defaults to document.body

insert.after(element, sibling[, parent])

  • element - string OR DOM element to insert
  • sibling - string or object of element to insert after
  • parent - string or DOM element of context of insert. Defaults to document.body

Run Tests

npm install
npm test