dom-matches
v2.0.0
Published
Check if a DOM element matches a given selector
Downloads
442,028
Maintainers
Readme
dom-matches
Check if a DOM element matches a given selector.
Installation
npm install dom-matches
API
matches(elem, selector)
elem
: a DOM node.selector
: a CSS selector string.
var matches = require('dom-matches');
var elem = document.querySelector('.foo');
matches(elem, '.foo');
// => true
matches(elem, '.bar');
// => false
Browser support
- Google Chrome
- Firefox ESR+
- Internet Explorer 10+
- Safari 6+
- Opera