$(function(){ let windName = window.location.pathname; let time = setInterval(function () { let m = $(".p_loopitem a").attr("href"); if (m) { console.log(m); $(".p_loopitem a").each(function () { let l_m = $(this).attr("href") if (l_m == windName) { $(this).parents('.p_loopitem').addClass("active") } }); clearInterval(time); } }, 100); $('.cateGoryArr').click(function(){ $(this).parent().next().next('.openthisMenu').animate({ height:'toggle' }); }); });