parent()

Returns the parents of the elements in a set. (In HTML, a parent is an element that contains another element.)
To get an ancestor that matches a particular selector, use closest() (see closest()).

Example

Assume that there are three paragraphs in a Box and that one of those paragraphs matches the selector of this script. The paragraph is stored in the results object (see results). The script retrieves the Box (which is the parent of the paragraph) using results.parent(), and then changes its background color to red.

results.parent().css('background-color' , 'red');
 
  • Last Topic Update: 16, February, 2018 03:50 PM
  • Last Published: 23, May, 2019 01:55 PM