var pathName = window.location.pathname; // 获得路径信息 $(".categrayBox a").each(function(){ // 遍历a链接的路径 var aLinkUrl = $(this).attr("href"); // 得到a链接的路径 if(aLinkUrl == pathName){ $(this).addClass("jpActive"); $(this).parent().addClass("jpActive"); return; } }); (function(){ new WOW().init(); $('a[href-data="top"]').on('click',function(){ $('html, body').animate({scrollTop: 0}, 'slow'); return false; }); })();