Skip to main content Accessibility Feedback



Check if an element would be selected by a particular selector or set of selectors. Returns true if the element is a match, and false when it’s not.

var elem = document.querySelector('#sandwich');
if (elem.matches('.turkey')) {
	console.log('It matches!');
} else {
	console.log('Not a match... =(');

Implemented with vendor prefixes in a handful of browsers. Use with a polyfill.