$(function () { var scp = $(".subNavList") if ($(window).width() < 798) { // 绉诲姩绔鍋氱殑浜 // 瀛愰泦鍏ㄩ儴闅愯棌 scp.find('.p_childBox').addClass('hide'); // 瀵艰埅鐨勫睍绀轰笌闅愯棌 $('.p_btn-show', scp).on('click', function () { $('.p_category', scp).toggleClass("animate") }); $('.p_btn-hide', scp).on('click', function () { $('.p_category', scp).toggleClass("animate") }) // 瀵艰埅瀛愰泦鐨勫睍绀轰笌闅愯棌 scp.find('.js_categoryBox').on('click', '.js_clickbtn', function () { var $this = $(this); //鎺у埗鍚岀骇浜掓枼 $this.closest('.p_parentBox').siblings('.p_parentBox').children('.p_childBox').addClass('hide') .siblings('div').children('.js_clickbtn').removeClass('icon-arrow_down').addClass('icon-arrow_up'); //灞曞紑鏀惰捣 if ($this.hasClass('icon-arrow_down')) { //鏀惰捣 $this.removeClass('icon-arrow_down').addClass('icon-arrow_up'); $this.closest('.p_parentBox').children('.p_childBox').addClass('hide'); } else { //灞曞紑 $this.removeClass('icon-arrow_up').addClass('icon-arrow_down'); $this.closest('.p_parentBox').children('.p_childBox').removeClass('hide'); } }) } var href = location.pathname + location.search; if (!href) return; scp.find('a').each(function (index, ele) { var hrefa = $(ele).attr('href'); if (hrefa == href) { $(ele).addClass("active"); $(ele).parents(".p_parentBox").children().children("a.p_title ").addClass("active"); } }) });