$(document).ready(function(){ //窗口滚动,改变导航栏背景色 $(window).scroll(function(){ if($("body").scrolltop()>400){ $(".navbar").css("background-color","#444"); } else { $(".navbar").css("background-color","rgba(0, 0, 0, 0.7)"); } }); $("#navbar li").mouseenter(function(){ $(this).find(".bkg").animate({ top:'0' },200); $(this).children('.submenu').css("display","block").animate({ top:'140px' },200); }); $("#navbar li").mouseleave(function(){ $(this).find(".bkg").animate({ top:'100%' },200); $(this).children('.submenu').css("display","none").animate({ top:'120px' },200); }); $(".suttit").mouseenter(function(){ $(this).children('a').css("color","#fff") }); $(".suttit").mouseleave(function(){ $(this).children('a').css("color","#333"); $(this).children('.current').css("color","#00a9e0"); }); //改变当前栏目的字体颜色 var channel1name = $("#channel1name").val();//一级栏目名称 var channel2name = $("#channel2name").val();//二级栏目名称 $(".channel1").each(function(){ if($(this).text()==channel1name) { $(this).parent().addclass("current"); } }); $(".channel2").each(function(){ if($(this).text()==channel2name) { $(this).addclass("current"); } }); //移动端 $(".menuicon-label").click(function(){ $("body").toggleclass("touch-open-menu"); }); $(".touch-nav .top-menu,.touch-footer .top-menu").each(function(){ if($(this).next(".submenu").children("a").length>0) { $(this).attr("href","javascript:void(0)"); } }); $(".touch-nav .top-menu,.touch-footer .top-menu").click(function(){ if($(this).next(".submenu").children("a").length>0) { if($(this).next(".submenu").is(":visible")) { $(this).next(".submenu").hide(); $(this).children(".icon-arrow").css("background-image","url(../images/icon-arrow-right.png)"); } else { $(this).children(".icon-arrow").css("background-image","url(../images/icon-arrow-down.png)"); $(this).closest("ul").find(".submenu").hide(); $(this).next(".submenu").show(); } } }); });