Jump to: navigation, search


This article is In Progress.

W3C Working Draft


The matches API checks if an element matches a given selector. While the old API used the name matchesSelector, the new one will use matches.

Method of dom/HTMLElement


var result = element.matchesSelector(selector);



Data-type: String

This string represents the selector to test the element against. This parameter is required and it must have a length of at least one. An empty string throws the error Dom Exception 12.

Return Value

Returns an object of type DOM Node.

Returns true if the element matches the given selector or false if it doesn't.


There is no data available for topic "webapi", feature "matchesSelector". If you think that there should be data available, consider opening an issue.

Needs Examples: This section should include examples.

{{Notes_Section |Usage=Currently, no browser vendor supports the unprefixed version. It is recommended to use the API as following:

var docEl = document.documentElement,
    matches = docEl.matches
|Sources=MDN, MSDN
|MSDN_link=[ Windows Internet Explorer API reference]