instance method Element#match

View source on GitHub →

Element#match(selector) → boolean
  • selector (String) – A CSS selector.

Checks if element matches the given CSS selector.

<ul id="fruits">
  <li id="apples">
      <li id="golden-delicious">Golden Delicious</li>
      <li id="mutsu" class="yummy">Mutsu</li>
      <li id="mcintosh" class="yummy">McIntosh</li>
      <li id="ida-red">Ida Red</li>


// -> true
// -> true
// -> false

This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.