src code

class method Element.up

Element.up(element[, expression[, index = 0]]) → Element
Element.up(element[, index = 0]) → Element
  • expression (String) – A CSS selector.

Returns element's first ancestor (or the Nth ancestor, if index is specified) that matches expression. If no expression is provided, all ancestors are considered. If no ancestor matches these criteria, undefined is returned.

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.