sdom-js

0.0.2 • Public • Published

sdom

sdom on NPM Standard JavaScript Style

Simple DOM element selection wrapper

Install

$ npm i sdom-js --save

Use

/**
 * {String} selector
 * {HtmlElement} scope default document
 *
 * @returns {Array|HtmlElement}
 */
sdom(selector, scope)

Note that if sdom matches only one element using provided selector, it will return HtmlElement, otherwise if it matches multiple elements will return Array of HtmlElements.

import sdom from 'sdom'

sdom('body')                // select document.body
sdom('head')                // select document.head
sdom('#id')                 // select by ID
sdom('.class')              // select by class 
sdom('div h1')              // select by tag name
sdom('[data-attr]')         // select by attribute
sdom('meta', head)          // changing default scope (document)
sdom('#id', sdom('.el'))

License

MIT. © 2018 Gardelin

Readme

Keywords

Package Sidebar

Install

npm i sdom-js

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

5.47 kB

Total Files

4

Last publish

Collaborators

  • gardelin