Nav('#nav')//导航 headerFix() mobideMenu()// 移动端主导航 divSelect() // 鼠标滑动导航置顶 function headerFix(){ var iWSon = document.documentElement.clientWidth; if(iWSon > 998){ var $windowHeight = $(window).height(); var bodyHeight = $(document.body).height() var $headerHeight = $('.gp-header').height()*2; $(window).scroll(function(){ var scrollTop = $(window).scrollTop(); if(scrollTop >= 89 && bodyHeight > $windowHeight+$headerHeight){ $('.gp-header').addClass('current'); $('.logo .logo_bg').slideDown(300); if($('.gp-header').hasClass('current')){ $('.headerFix-menu').fadeIn(300); // $('.gp-header.current .top').slideUp(300); // $('.logo_01').find('image').attr({width:180,height:42}) // $('.logo_01').find('svg').attr({width:180,height:42}) } }else{ $('.gp-header').removeClass('current'); $('.logo .logo_bg').slideUp(300); if($('.gp-header').hasClass('current')){ $('.headerFix-menu').fadeIn(300); }else{ $('.headerFix-menu,.headerFix-close').fadeOut(300); // $('.gp-header .top').slideDown(300) // $('.logo_01').find('image').attr({width:267,height:62}) // $('.logo_01').find('svg').attr({width:267,height:62}) } } }) } $('.headerFix-menu').click(function(){ $('.header.current .top').slideDown(300) $(this).fadeOut(100); $('.headerFix-close').fadeIn(300) }) $('.headerFix-close').click(function(){ $(this).fadeOut(300) $('.header.current .top').slideUp(300); $('.headerFix-menu').fadeIn(300) }) } /* 下拉菜单例调用:Nav('#nav'); */ function Nav(id){ var oNav = $(id); var aLi = oNav.find('li'); aLi.hover(function (){ $(this).addClass('on'); $(this).find('.subNav').addClass('zoomIn'); },function (){ $(this).removeClass('on'); $(this).find('.subNav').removeClass('zoomIn'); })}; /* 搜索点击弹出效果例调用:SerMax('#gp-serBtn2','#gp-search2'); */ // function SerMax(){ // var searchTarget; // $(".serBtn > i").click(function(e){// searchTarget=e.target; // $(".ser").animate({width:"200px"}); // $(this).hide(); // }) // $(".ser").click(function(e){ // searchTarget=e.target; // //搜索框搜索事件 // }) // $("html").click(function(event) { // if (event.target !=searchTarget) { // $(".ser").animate({width:"0"},300); // //$(".ser").delay(300).hide(); // $(".serBtn >i").show(); // } // }); // } /* 移动端主导航例调用:mobileMenu('#gp-menu'); */ function mobideMenu(){ $(".mobile-inner-header .mobile-inner-header-icon").click(function(){ $(this).toggleClass("mobile-inner-header-icon-click mobile-inner-header-icon-out"); $('body').toggleClass('nav-open'); $('.black_bg01').slideToggle(200) }); $('.black_bg01').click(function(){ $(".mobile-inner-header .mobile-inner-header-icon").toggleClass("mobile-inner-header-icon-click mobile-inner-header-icon-out"); $('body').toggleClass('nav-open'); $(this).slideToggle(300) $('.logo').slideToggle(200) }) $(".mobile-inner-nav li > a").each(function( index ) { $( this ).css({'animation-delay': (index/20)+'s'}); }); $('.mobile-search-btn').click(function(){ $('.mobile_search').slideToggle(300) }) $('.mobile-inner-nav li strong').click(function(){ $(this).parent().toggleClass('on'); if($(this).parent().hasClass('on')){ $(this).addClass('icon-fanhui-copy ') $(this).removeClass('icon-fanhui') $(this).next('.mobile_subNav').slideDown(300) }else{ $(this).addClass('icon-fanhui') $(this).removeClass('icon-fanhui-copy'); $(this).next('.mobile_subNav').slideUp(300) } }) } /* tab切换 例调用:$(".tab").tab({ev : 'mouseover',more : false,auto : false}); */ ;(function($){ $.fn.extend({ tab: function (options){ var defaults = { //默认参数 ev : 'mouseover', //默认事件'mouseover','click' delay : 100, //延迟时间 auto : true, //是否自动切换 true,false speed : 2000, //自动切换间隔时间(毫秒) more : false //是否有more,false,true }; var options = $.extend(defaults, options); //用户设置参数覆盖默认参数 return this.each(function (){ var o = options; var obj = $(this); var oTil = obj.find('.til_tab'); var oBox = obj.find('.tabListBox'); var oMore = null; var iNum = 0; var iLen = oTil.length; obj.find('.til_tab').eq(0).addClass('on') obj.find('.tabListBox').eq(0).css('display','block') obj.find('.more_tab').eq(0).css('display','block') //鼠标事件绑定 oTil.bind(o.ev , function (){ var _this = this; if(o.ev == 'mouseover' && o.delay){ _this.timer = setTimeout(function (){ change(_this); },o.delay); }else{ change(_this); }; }) oTil.bind('mouseout',function (){ var _this = this; clearTimeout(_this.timer); }); //自动切换效果 (function autoPlay(){ var timer2 = null; if(o.auto){ function play(){ iNum++; if(iNum >= iLen){ iNum =0; }; change(oTil.eq(iNum)); }; timer2 = setInterval(play,o.speed); obj.on('mouseover',function (){ clearInterval(timer2); }) obj.on('mouseout',function (){ timer2 = setInterval(play,o.speed); }) }; })(); function change(box){ iNum = $(box).index(); oTil.removeClass('on'); oBox.css('display','none'); if(o.more){ oMore = obj.find('.more_tab'); oMore.css('display','none'); oMore.eq(iNum).css('display','block'); }; oTil.eq(iNum).addClass('on'); oBox.eq(iNum).css('display','block'); } }); } }) })(jQuery); /* 返回顶部 */ $(window).scroll(function(){ var docHeight = $(document).height() var winHeight = $(window).height(); var scrollTop = $(window).scrollTop(); if(scrollTop >= 165){ $('.gp-goTop').fadeIn(500) }else{ $('.gp-goTop').fadeOut(500) } if(scrollTop >= docHeight - winHeight){ $('.gp-goTop-fixed').addClass('bottom') }else{ $('.gp-goTop-fixed').removeClass('bottom') } }) $('.gp-goTop').click(function(){ $('body,html').stop().animate({scrollTop:0}); return false; }); /* 奇数偶数不同的样式 例调用: odd= {"background":"#fff","color":"#666"};//奇数样式 even={"background":"#f7f7f5","color":"#666"};//偶数样式 单个元素: odd_even('.list',odd,even,'tr');多个元素: odd= {"background":"#fff","color":"#666"};//奇数样式 even={"background":"#f7f7f5","color":"#666"};//偶数样式 $('.list').each(function(){ odd_even($(this),odd,even,'tr'); }) */ function odd_even(id,odd,even,className){ $(id).find(className).each(function(index,element){ if(index % 2 == 1){ $(this).css(odd); $(this).addClass('odd'); } else{ $(this).css(even); $(this).addClass('even'); } }); } /* 侧边栏三级 例调用: asideMenu('#gp-subLeft') */ function asideMenu(menu){ //当前状态高亮 $(menu).find('.active').each(function(){ if($(this).parents('dl').hasClass('gp-second-nav')){ $(this).parents('dl').css('display','block'); $(this).parents('li').addClass('active') $(this).parents('li').find('.gp-toggles').addClass('icon-down').removeClass('icon-right'); } }) $(menu).find('.gp-toggles').click(function(){ if($(this).parents('li').hasClass('active')){ $(this).addClass('icon-right').removeClass('icon-down') $(this).next('.gp-second-nav').slideUp(500) $(this).parents('li').removeClass('active') }else{ $(this).addClass('icon-down').removeClass('icon-right'); $(this).next('.gp-second-nav').slideDown(500); $(this).parents('li').siblings().find('.gp-second-nav').slideUp(500) $(this).parents('li').siblings().removeClass('active') $(this).parents('li').siblings().find('.gp-toggles').addClass('icon-right').removeClass('icon-down') $(this).parents('li').addClass('active') } }) } //移动端侧边栏菜单 function mobileAsideMenu(menu,main){ $(menu).find('.gp-m-inner-header').click(function(){ $(this).toggleClass("gp-m-inner-header-icon-click gp-m-inner-header-icon-out"); $(this).find('.iconfont').toggleClass("icon-jia icon-jian") $(".gp-subNavm").slideToggle(500); }); $('.gp-subNavm').find('.gp-m-toggle').click(function(){ if($(this).parents('li').hasClass('active')){ $(this).addClass('icon-right').removeClass('icon-down') $(this).next('dl').slideUp(500) $(this).parents('li').removeClass('active') }else{ $(this).addClass('icon-down').removeClass('icon-right'); $(this).next('dl').slideDown(500); $(this).parents('li').siblings().find('dl').slideUp(500) $(this).parents('li').siblings().removeClass('active') $(this).parents('li').siblings().find('.gp-m-toggle').addClass('icon-right').removeClass('icon-down') $(this).parents('li').addClass('active') } }) }; /*友情链接*/ function divSelect(){ $('.divSelect').each(function(){ var citeText = $(this).find('ul li').eq(0).text() $(this).find('cite').text(citeText); }) $('.divSelect').find('cite').click(function (event) { //取消事件冒泡 event.stopPropagation(); $(this).next('ul').slideToggle(300); $(this).parent().toggleClass('active'); return false; }); //点击空白处隐藏弹出层,下面为滑动消失效果和淡出消失效果。 $(document).click(function(event){ var _con = $('.divSelect'); // 设置目标区域 if(!_con.is(event.target) && _con.has(event.target).length === 0){ //$('#divTop').slideUp('slow'); //滑动消失 $('.divSelect').find('.linkList02').slideUp(300); //淡出消失 $('.divSelect').removeClass('active') } }); } //分页下拉列表框 function pageSelect(){ console.log($('.pageSelect').length) if($('.pageSelect').length!=0){ $('.pageSelect').select2({}); $("#select21").on("change",function(){ window.location.href=$(this).val() }) $("#select22").on("change",function(){ var $thval=$(this).val() if($thval=="") return false; //value 绱㈠紩浠�0寮€濮� $(".camel-list .list").eq($thval).find(".demo-img:first").click(); }) } }