0.0.2 • Published 6 years ago
sdom-js v0.0.2
sdom
Simple DOM element selection wrapper
Install
$ npm i sdom-js --saveUse
/**
* {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