0.0.2 • Published 5 years ago

sdom-js v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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