searches up the DOM tree for the closest element code example
Example 1: jquery nearest
$( "li.item-a" )
.closest( "ul" )
.css( "background-color", "red" );
Example 2: jquery get closest form
$( this ).closest( "form" )
$( "li.item-a" )
.closest( "ul" )
.css( "background-color", "red" );
$( this ).closest( "form" )