Skip to content
Html or css selector into DOM elements
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
README.md
index.js
package.json

README.md

domy-element

Html or css selector into DOM elements. For use with Browserify.

Part of the Domy module collection.

browser support

Install

npm install domy-element --save

Usage

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

var el = element('#someId').one(); // single
var els = element('.item').all(); // multiple

var el = element('<div class="item"></div>').one();
var el = element(document.body).one();

// In context
var items = element('.parent').all('.items');

Element

element(data);

  • data - a string, css selector, or DOM element
    • Example 1: element('<div class="item"></div>').one() - returns a DOM element with a class of item
    • Example 2: element(document.body).one() - returns the body DOM element
    • Example 3: element('body').one() - returns the body DOM element

Instance Methods

all([selector])

Returns an array of DOM elements

  • selector - css selector. If used, selector will select all DOM elements within the context of the parent selector used in the element() method.

one([selector])

Returns a single DOM element

  • selector - css selector. If used, selector will select the first matching DOM elements within the context of the parent selector used in the element() method.

Run Tests

Requires Phantomjs is installed

npm install
npm test
Something went wrong with that request. Please try again.