Element.matches()

The DOM method that returns true if an element would be selected by a given CSS selector.

In more detail

It accepts any CSS selector string. It tests one element without searching the tree, which makes it a quick check inside event handlers, such as whether the clicked element is a delete button.

Related terms

Taught in

References