Element.matches()
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... =(');
}