$("#m" + m).addClass("aon"); $("#m2 em a").eq(0).attr("href", $("#m2 .sub .list h2 a").eq(0).attr("href")); $("#m3 em a").eq(0).attr("href", $("#m3 .sub .list h2 a").eq(0).attr("href")); $("#m6 h2 a").each(function () { var a = $(this).parent().next().find("dt"); if (a.length > 0) { $(this).attr("href", a.find("a").eq(0).attr("href")); } else { var b = $(this).parent().next().find("dd"); if (b.length > 0) { $(this).attr("href", b.find("a").eq(0).attr("href")); } } }); //$("#dt98 a").attr("href", $("#dt98").attr("data-url")); $("#dt97 a").eq(0).attr("href", $("#dt97").next().find("a").attr("href")); //打开搜索 $(".open-search").click(function (e) { if ($(this).hasClass("open-search-show")) { $(this).removeClass("open-search-show"); } else { $(this).addClass("open-search-show"); } $(".search-box").stop(true, true).fadeToggle(); $(document).on("click", function () { $(".search-box").stop(true, true).fadeOut(); $(".open-search").removeClass("open-search-show"); }); e.stopPropagation(); }); $(".search-box").on("click", function (e) { e.stopPropagation(); }); //下拉菜单 $(".top-menu li").each(function () { var e = $(this).find(".sub").length if (e >= 1) { var _this = $(this); $(this).addClass("has-sub"); $(this).mouseDelay(false).hover(function (e) { var gid = $(this).find("em").attr("data"); if(gid != 38){ $("#m0").removeClass( "hover" ); $("#m0 .sub").css('display','none'); } var url = '//'+window.location.host+"/verify/togetsub/"+gid;//http://test.ecotek.com.cn/verify/togetsub/ $.ajax({ type:'GET', contentType:"application/json;charset=utf-8", url:url, dataType:'json', success:function(result){ _this.find(".sub").html(result); } }); $(this).find(".sub").stop(true, true).slideDown(); // $(this).find(".sub").stop(true, true).css('display','block'); $(this).addClass("hover"); $(this).find("em a").css('color','#027BB8'); }, function () { $(this).removeClass("hover"); $(this).find(".sub").stop(true, true).slideUp(); $(this).find("em a").css('color','#404040'); // $(this).find(".sub").stop(true, true).css('display','none'); }); } }); //复制导航菜单 $("#top-menu .mnav").html($(".top-menu").html()); $("#m8 h2 a").attr("href", "/gene.html"); $("#top-menu .site-group").append( $('.Top .top-right dt').html()); //去除移动端ID $("#top-menu .mnav li").removeAttr("id"); //打开移动端菜单 $(".wap-open-menu").click(function (e) { if ($(this).hasClass("wap-close-menu")) { $(this).removeClass("wap-close-menu"); $(".Top").removeClass("Top-wap"); $("#top-menu").css({"top":0,height:0}) $('body,html').css("overflow","auto"); ///清除二级菜单选择 setTimeout(function(){ $("#top-menu .mnav ul").removeClass("sub-show"); $("#top-menu .tab-list").css("overflow","auto"); $("#top-menu .mnav li .sub").hide(); $("#top-menu .tab li").eq(0).click(); },300); // } else { $(this).addClass("wap-close-menu"); $('body,html').css("overflow","hidden"); var sH=$(".search-box").outerHeight()+$(".Top").outerHeight()-1; var wH=$(window).outerHeight()+1; $("#top-menu").css({"top":sH,height:wH}) $(".Top").addClass("Top-wap"); } }); //移动端文字大小 function fontsize() { var windowwidth = parseInt($(window).width()); if (windowwidth <= 1024) { var size = windowwidth*16/375; $('html').css('font-size',size + 'px'); } else{ $('html').removeAttr('style'); } }; //头部标签内容宽度 function tablistH(){ var a=$(".Top").outerHeight() var b=$(".search-box").outerHeight() var c=$("#top-menu .tab").outerHeight() // alert(c) var sHB=a+b+c var wHB=$(window).outerHeight(); var allH=wHB-sHB $("#top-menu .tab-list").outerHeight(allH); $(".top-Height").remove(); $(".Top").after("
"); } tablistH(); fontsize(); $(window).resize(function(e) { tablistH(); fontsize(); if($(".Top").hasClass("Top-wap")){ var sH=$(".search-box").outerHeight()+$(".Top").outerHeight()-1; var wH=$(window).outerHeight(); $("#top-menu").css({"top":sH,height:wH}) } }); //头部标签切换 $("#top-menu .tab li").click(function(e) { var e=$(this).index(); $(this).addClass("on"); $(this).siblings().removeClass("on"); $("#top-menu .tab-list").find(".tab-info").eq(e).show() $("#top-menu .tab-list").find(".tab-info").eq(e).siblings().hide(); tablistH() //清除 $("#top-menu .mnav ul").removeClass("sub-show"); $("#top-menu .tab-list").css("overflow","auto"); $("#top-menu .mnav li .sub").hide(); }); $("#top-menu .tab li").eq(0).click(); //增加二级导航返回 $("#top-menu li.has-sub").each(function () { var e = $(this).find("em a").text() $(this).find(".sub .auto").before("
"+e+"
"); }); //打开二级菜单 $("#top-menu li.has-sub em").click(function(){ $("#top-menu .mnav ul").addClass("sub-show"); $(this).next(".sub").fadeIn(); $("#top-menu .tab-list").css({"overflow":"inherit"}).scrollTop(0); var sunbackH=$(window).outerHeight()-$(".search-box").outerHeight()-$(".Top").outerHeight()- $("#top-menu .tab").outerHeight()-$(this).next(".sub").find(".back").outerHeight(); $("#top-menu .mnav li .sub .auto").css("max-height",sunbackH).scrollTop(0); }); //返回一级菜单 $(".sub .back").click(function(e) { $(this).parent(".sub").fadeOut(); $("#top-menu .mnav ul").removeClass("sub-show"); $("#top-menu .tab-list").css("overflow","auto").scrollTop(0); $("#top-menu .mnav li .sub .auto").scrollTop(0); }); //获取链接地址 $("#top-menu .mnav li:not(:nth-child(5)) dt").each(function() { var e=$(this).next("dd").length if(e>=1){ var links=$(this).next("dd").eq(0).find("a").attr("href"); $(this).find("a").attr("href",links); } });