instead of using parent().parent().parent() we can use closest
$( "li.item-a" ) .closest( "ul" ) .css( "background-color", "red" );