var loc = window.location.pathname; $('.service-list').find('a').each(function () { $(this).parents('li').toggleClass('active', $(this).attr('href') == loc); }); })