function ispc() { var useragentinfo = navigator.useragent; var agents = new array("android", "iphone", "symbianos", "windows phone", "ipad", "ipod"); var flag = true; for (var v = 0; v < agents.length; v++) { if (useragentinfo.indexof(agents[v]) > 0) { flag = false; break; } } //alert(flag); return flag; } $(document).ready(function(){ //返回顶部 $("#gototop").click(function(){ $("html,body").animate({scrolltop :0}, 800);return false; }); $("#gotocate").click(function(){ $("html,body").animate({scrolltop:$("#classification").offset().top - 50},800); return false; }); $("ul.menu_body").each(function(){ if ($(this).text().replace(/[\r\n ]/g,"").length<=0) {$(this).prev().remove();} //去掉span }); $("#firstpane span").click(function(){ var spanatt = $(this).next("ul").css('display'); if (spanatt == "block"){ var spantext = "+"; // $(this).prev().removeclass("left_active"); }else{ var spantext = "-"; //$(this).prev().addclass("left_active"); } $(this).html(spantext).addclass("current").next("ul").slidetoggle(300).siblings("ul"); }); //导航无分类就隐藏 if($("#firstpane").children().length == 0) { $("#classification").hide(); } if($(".firstselected") != null) { $(".firstselected").next("span").html("-"); $(".firstselected").next("span").next("ul").slidetoggle(300); } $("#smallsearch").click(function(){ $(".searchbox").slidetoggle(); }); }); //把导航中没有子元素的ul和展开按钮删除 $('.dropdown').each(function(i){ var len = $(this).children(".dropdown-menu").children().length; if(len==0) { $(this).children("#app_menudown").hide(); $(this).children(".dropdown-menu").hide(); $(this).children('.dropdown-toggle').dropdownhover(); $(this).children('a.dropdown-toggle').one('click',function(){ location.href= $(this).attr('href'); }); } }) //如果是电脑版的就鼠标悬停展开下级菜单 if($(window).width() >= 768 && ispc()) { $('.dropdown-toggle').dropdownhover(); $('a.dropdown-toggle').one('click',function(){ location.href= $(this).attr('href'); }); $(".dropdown-menu li").hover(function(){$(this).children("ul").toggle();}); } //底部产品 $(".bottombutton").click(function(){ for(var i = 1;i < 4;i++) { if($(this).attr('id') == "bottomproductbtn" + i) { $("#bottomproductbtn" + i).addclass("selectedbottombutton"); $("#bottomproductlist" + i).show(); }else{ $("#bottomproductbtn" + i).removeclass("selectedbottombutton"); $("#bottomproductlist" + i).hide(); } } });