js get nearest element with class code example Example: jquery nearest $( "li.item-a" ) .closest( "ul" ) .css( "background-color", "red" );