For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
Optional
Selector for the element to find.
The closest nodes.
$('.orange').closest();//=> []$('.orange').closest('.apple');// => []$('.orange').closest('li');//=> [<li class="orange">Orange</li>]$('.orange').closest('#fruits');//=> [<ul id="fruits"> ... </ul>] Copy
$('.orange').closest();//=> []$('.orange').closest('.apple');// => []$('.orange').closest('li');//=> [<li class="orange">Orange</li>]$('.orange').closest('#fruits');//=> [<ul id="fruits"> ... </ul>]
https://api.jquery.com/closest/
For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.