domy-children

Manipulate children of DOM elements

domy-children

Manipulate children of DOM elements. For use with Browserify.

Part of the Domy module collection.

npm install domy-children --save
var chidren = require('domy-children');
 
children('<div><span></span><span></span></div>').first();
children('.parent').last();
children(document.body).at(1);
children('<div><span></span><span></span></div>').count();
  • element - string, css selector, or DOM element

Creates and returns an object with the following methods available:

  • remove
  • first
  • last
  • count
  • at

Remove all children with the following selector

  • selector - DOM element or css selector

Get the first child node

Get the last child node

Get child at index

  • index - index of child node to return

Get number of child nodes

Requires Phantomjs is installed

npm install
npm test