Skip to content
Lightweight querySelector/All wrapper that outputs an Array
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

select-dom gzipped size Travis build status npm downloads

Lightweight querySelector/All wrapper that outputs an Array

Version 5+ only supports browsers with Set support. If you need IE 10- support, stick to select-dom@4


$ npm install select-dom
const select = require('select-dom')
import select from 'select-dom';


Note: if a falsy value is passed as baseElement, you'll always get an empty result (bd578b9)

select(selector[, baseElement = document])

Maps to baseElement.querySelector(selector)

select('.foo a[href=bar]')
// => <Element>

select('.foo a[href=bar]', baseElement)
// => <Element>

select.last(selector[, baseElement = document])

Like select(), except that it returns the last matching item on the page instead of the first one.

select.exists(selector[, baseElement = document])

Tests the existence of one or more elements matching the selector. It's like select(), except it returns a boolean.

select.exists('.foo a[href=bar]')
// => true/false

select.exists('.foo a[href=bar]', baseElement)
// => true/false

select.all(selector[, baseElements = document])

Maps to baseElements.querySelectorAll(selector) plus:

  • it always returns an array
  • baseElements can be a list of elements to query
// => [<Element>, <Element>, <Element>]

select.all('.foo', baseElement)
// => [<Element>, <Element>, <Element>]

select.all('.foo', [baseElement1, baseElement2])
// => [<Element>, <Element>, <Element>]
// This is similar to jQuery([baseElement1, baseElement2]).find('.foo')


  • delegate-it - DOM event delegation, in <1KB.
  • doma - Parse an HTML string into DocumentFragment or one Element, in a few bytes.
  • Refined GitHub - Uses this module.
You can’t perform that action at this time.