$(function() { $('.d-firstNav').click(function(e) { console.log("111"); dropSwift($(this), '.d-firstDrop'); e.stopPropagation(); }); $('.d-secondNav').click(function(e) { dropSwift($(this), '.d-secondDrop'); e.stopPropagation(); }); /** * @param dom 點擊的當前元素 * @param drop 下一級菜單 */ function dropSwift(dom, drop) { //點擊當前元素,收起或者伸展下一級菜單 dom.next().slideToggle(); //設置旋轉效果 //1.將所有的元素都至為初始的狀態 dom.parent().siblings().find('.fa-caret-right').removeClass('iconRotate'); //2.點擊該層,將其他顯示的下滑層隱藏 dom.parent().siblings().find(drop).slideUp(); var iconChevron = dom.find('.fa-caret-right'); if(iconChevron.hasClass('iconRotate')) { iconChevron.removeClass('iconRotate'); } else { iconChevron.addClass('iconRotate'); } } //判斷當超過多少字符,行間距設為初始化 $(".mesgopen2 li a").each(function(){ if(($(this).text().length<40) && ($(this).text().length>34)){ $(this).next(".date").css("display","block"); $(this).css("line-height","normal"); $(this).parent("li").css("padding","17px 0"); }else if($(this).text().length>=40){ $(this).css("line-height","normal"); $(this).parent("li").css("padding","17px 0"); } }) // $(".gknr_ul .gknr_conList").click(function(){ $(this).addClass("open").siblings().removeClass("open"); }) $(".gknr_ul .submenu li").click(function(){ $(this).addClass("active").siblings().removeClass("active"); }) $("#accordion>li").click(function(){ if($(this).find(".link").text().indexOf("政府信息公開目錄")<0){ $(".gknr_ul").hide(); } }) })