We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Element.mozMatchesSelector Redirect 1

« DOM Reference

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.


Returns true if the element would be selected by the specified selector string; otherwise, returns false.

Most browsers implements this, prefixed, under the non-standard name matchesSelector().


result = element.matches(selectorString) 
  • result holds the return value true or false.
  • selectorString is a string representing the selector to test.


  <div id="foo">This is the element!</div>
  <script type="text/javascript">
    var el = document.getElementById("foo");
    if (el.matches("div")) {

This will alert, since the element is indeed a <div>.


The specified selector string is invalid.


Specification Status Comment
Selectors API Level 2
The definition of 'Element.matches' in that specification.
Working Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support

(Yes) with the non-standard name webkitMatchesSelector

3.6 (1.9.2) with the non-standard name mozMatchesSelector [1] 9.0 with the non-standard name msMatchesSelector 11.5 with the non-standard name oMatchesSelector
15.0 with the non-standard name webkitMatchesSelector
5.0 with the non-standard name webkitMatchesSelector
Unprefix version 34 ? ? ? ?
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? 1.0 (1.9.2) with the non-standard name mozMatchesSelector [1] ? ? ?

[1] Prior to Gecko 2.0, invalid selector strings caused false to be returned instead of throwing an exception.

Document Tags and Contributors

Last updated by: Sheppy,