class method Element.descendantOf

View source on GitHub →

Element.descendantOf(element, ancestor) → Boolean
  • ancestor (Element | String) – The element to check against (or its ID).

Checks if element is a descendant of ancestor.



<div id="australopithecus">
  <div id="homo-erectus">
    <div id="homo-sapiens"></div>


// -> 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.