node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org »

fd-insert-after

fd-insert-after

Build Status npm version

insert after a DOM element in a functional way.

Installation

npm install fd-insert-after --save

Usage

Let the DOM be like:

<div id="parentElement">
  <span id="childElement">foo bar</span>
</div>```
 
 
```js
let insertAfter = require('fd-insert-after');
 
let sp1 = elem("span","meow")
,sp2 = document.getElementById("childElement")
,parentDiv = sp2.parentNode
 
insertAfter(sp1, sp2);
 
selectOne('#parentElement').children[0].innerText; // => 'foo bar'

API

insert-after :: refNode -> newNode

A curried function that takes in:

  • refNode The node after which newChild is inserted.

  • newChild The node to insert.