xxxxxxxxxx
// Using jQuery's closest() method to find the closest element with a specific class
var closestElement = $(".target-element").closest(".class-to-find");
xxxxxxxxxx
$( "li.item-a" )
.closest( "ul" )
.css( "background-color", "red" );
xxxxxxxxxx
// Assuming 'element' is the current element from which we want to find the closest parent
var closestParent = $(element).closest('selector');