Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (25 sloc) 599 Bytes


Build Status

Check if a DOM element matches a given selector.


npm install dom-matches


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
You can’t perform that action at this time.