Skip to content

matches

Toke Voltelen edited this page Dec 3, 2016 · 3 revisions

matches(elm, selector)

Determines whether or not a HTML Element matches a given CSS selector

Parameters

  • elm (HTMLElement) - HTML Element to test
  • selector - CSS selector elm should match
  • returns (Boolean) - Whether or not elm matched the selector

Usage

import matches from 'vanillajs-helpers/matches';

matches(element, '#someId .some-class') // -> true
Clone this wiki locally