/*导航条*/ $(function(){ $('.nav20 .nav li').mouseenter(function(){ var width=$(this).outerWidth(); var left=$(this).position().left; var index=$(this).index('.nav20 .nav li'); $(this).addClass('active').siblings().removeClass('active'); $(this).closest('.nav').find('.line').css({'width':width}).stop().animate({'left':left}); }); }); /*手机header导航*/ $(function(){ $('.headerwrap .header .c1').on('click',function(event){ var isOpen=$(this).closest('.headerwrap').hasClass('open'); $(this).closest('.headerwrap')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); }); /* 首页轮播图 */ $(function(){ var intervalTime = 3000, continueTime = 800, index = 0, timeTask, _width; var _length = $('.container1 .c-left .banner1 .pic li').length - 1; var _width=$('.container1 .c-left .banner1').width(); $('.banner1 .bar li').mouseover(function(){ clearInterval(timeTask); index = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.container1 .c-left .content .i-body').eq(index).addClass('active').siblings().removeClass('active'); $('.container1 .c-left .banner1 .pic').animate({'left':-index*_width}); timeTask = setInterval(slideImg, intervalTime); }); //定时器 function slideImg(){ index = index>=_length?0:++index; $('.banner1 .bar li').eq(index).addClass('active').siblings().removeClass('active'); $('.container1 .c-left .content .i-body').eq(index).addClass('active').siblings().removeClass('active'); $('.container1 .c-left .banner1 .pic').animate({'left':-index*_width}); } timeTask = setInterval(slideImg, intervalTime); }); /*动态tab*/ $(function(){ $('.container2 .tab .tab-header li').mouseenter(function(){ var width=$(this).outerWidth(); var left=$(this).position().left; var index=$(this).index('.container2 .tab .tab-header li'); $(this).addClass('active').siblings().removeClass('active'); $(this).closest('.tab-header').find('.line').css({'width':width}).stop().animate({'left':left}); $('.container2 .tab .tab-body ul').eq(index).addClass('active').siblings().removeClass('active'); }); }); $(document).ready(function(){ $("#layout-t span:first").addClass("current"); $("#layout-t .tab-bd-con:gt(0)").hide(); $("#layout-t span").mouseover(function(){//mouseover 改为 click 将变成点击后才显示,mouseover是滑过就显示 $(this).addClass("current").siblings("span").removeClass("current"); $("#layout-t .tab-bd-con:eq("+$(this).index()+")").show().siblings(".tab-bd-con").hide().addClass("current"); }); $(".list-tweet >li").mouseover(function(){ $(this).removeClass("drink-me"); $(this).addClass("eat-me"); $(".list-tweet >li:first").removeClass("eat-me"); $(".list-tweet >li:first").addClass("drink-me"); }); $(".list-tweet >li").mouseout(function(){ $(this).removeClass("eat-me"); $(this).addClass("drink-me"); $(".list-tweet >li:first").addClass("eat-me"); $(".list-tweet >li:first").removeClass("drink-me"); }); $(".list-tweet >li").mouseover(function(){ $(this).removeClass("drink-me"); $(this).addClass("eat-me"); }); }); /*大事记tab*/ ;( function( window ) { 'use strict'; function extend( a, b ) { for( var key in b ) { if( b.hasOwnProperty( key ) ) { a[key] = b[key]; } } return a; } function CBPFWTabs( el, options ) { this.el = el; this.options = extend( {}, this.options ); extend( this.options, options ); this._init(); } CBPFWTabs.prototype.options = { start : 0 }; CBPFWTabs.prototype._init = function() { // tabs elems this.tabs = [].slice.call( this.el.querySelectorAll( 'nav > ul > li' ) ); // content items this.items = [].slice.call( this.el.querySelectorAll( '.content-wrap > section' ) ); // current index this.current = -1; // show current content item this._show(); // init events this._initEvents(); }; CBPFWTabs.prototype._initEvents = function() { var self = this; this.tabs.forEach( function( tab, idx ) { tab.addEventListener( 'click', function( ev ) { ev.preventDefault(); self._show( idx ); } ); } ); }; CBPFWTabs.prototype._show = function( idx ) { if( this.current >= 0 ) { this.tabs[ this.current ].className = this.items[ this.current ].className = ''; } // change current this.current = idx != undefined ? idx : this.options.start >= 0 && this.options.start < this.items.length ? this.options.start : 0; this.tabs[ this.current ].className = 'tab-current'; this.items[ this.current ].className = 'content-current'; }; // add to global namespace window.CBPFWTabs = CBPFWTabs; })( window ); /*科协组织tab*/ $(function(){ $('.container10 .c-right .tab2 .tab-header li').on('click',function(){ var width=$(this).outerWidth(); var index=$(this).index('.container10 .c-right .tab .tab-header li'); $(this).addClass('active').siblings().removeClass('active'); $(this).closest('.tab-header').on('click',function(){ $(this).closest('.tab-header').find('.line').stop().animate({'left':index*width-1}); $('.container10 .c-left .c-body .tab .tab-body dd').siblings().removeClass('active'); $('.container10 .c-right .tab .tab-body li').eq(index).addClass('active').siblings().removeClass('active'); }); }); /*左年份tab*/ $('.container10 .c-left .c-body .tab .tab-header li').on('click',function(){ var width=$(this).outerWidth(); var index=$(this).index('.container10 .c-left .c-body .tab .tab-header li'); $(this).addClass('active').siblings().removeClass('active'); $(this).closest('.tab-header').on('click',function(){ $(this).closest('.tab-header').find('.line').stop().animate({'left':index*width}); $('.container10 .c-left .c-body .tab .tab-body dd').siblings().removeClass('active'); $('.container10 .c-left .c-body .tab .tab-body li').eq(index).addClass('active').siblings().removeClass('active'); }); }); $('.container10 .c-right .tab2 .tab-header dd').mouseenter(function(){ var width=$(this).outerWidth(); var index=$(this).index('.container10 .c-right .tab .tab-header dd'); $(this).addClass('active').siblings().removeClass('active'); $(this).closest('.tab-header').on('click',function(){ $('.container10 .c-right .c-body .tab .tab-body li').siblings().removeClass('active'); $('.container10 .c-right .c-body .tab .tab-body dd').eq(index).addClass('active').siblings().removeClass('active'); }); }); $('.container10 .c-left .tab .tab-header dd').mouseenter(function(){ var width=$(this).outerWidth(); var index=$(this).index('.container10 .c-left .c-body .tab .tab-header dd'); $(this).addClass('active').siblings().removeClass('active'); $(this).closest('.tab-header').on('click',function(){ $('.container10 .c-left .c-body .tab .tab-body li').removeClass('active'); $('.container10 .c-left .c-body .tab .tab-body dd').eq(index).addClass('active').siblings().removeClass('active'); }); }); }); $(function(){ /*服务窗口*/ var step=0; var index=$('.container3 .c-body .content .box ul li').length; var _width=$('.container3 .c-body .content .box ul li').width(); $('.container3 .c-body .icon-arrow-right').on('click',function(){ if(step<6){ step+=3; }else if(step==6){ step=8; } $('.container3 .c-body .content .box').animate({'left':-step*_width}); if(step==8){ step=-3; } }); $('.container3 .c-body .icon-arrow-left').on('click',function(){ //number=(number<=0)?0:(number-3); if(step<3){ step=0; }else if(step>=3){ step-=3; } $('.container3 .c-body .content .box').animate({'left':-step*_width}); }); }); $(function(){ $('.nav20 .nav-btn').on('click',function(event){ var isOpen=$(this).closest('.nav20').hasClass('open'); $(this).closest('.nav20')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); $('body').on('click',function(event){ $('.nav20').removeClass('open'); event.stopPropagation(); }); }); /*响应式导航按钮*/ $(function(){ $('.container9 .c-left .c-body .tab .fa-list-ul').on('click',function(event){ var isOpen=$(this).closest('.tab').hasClass('open'); $(this).closest('.tab')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); $('body').on('click',function(event){ $('.tab').removeClass('open'); event.stopPropagation(); }); }); /*大事记*/ $(function(){ $('.container9 .c-left .c-body .tab .fa-list-ul').on('click',function(event){ var isOpen=$(this).closest('.tab').hasClass('open'); $(this).closest('.tab')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); $('body').on('click',function(event){ $('.tab').removeClass('open'); event.stopPropagation(); }); }); /*大事记——更多*/ $(function(){ $('.container9 .c-left .c-body .tab .tab-header .more').on('click',function(event){ var isOpen=$(this).hasClass('open'); $(this).closest('.tab-header').find('dl')[isOpen?'hide':'show'](); if(isOpen==false){ $(this).closest('.tab-header').height(120); }else{ $(this).closest('.tab-header').height(80); } $(this)[isOpen?'removeClass':'addClass']('open'); }); }); /*创新服务*/ $(function(){ $('.youqinglianjie .c-body .c-right li a').click(function(){ var isOpen=$(this).closest('li').hasClass('open'); $(this).closest('li')[isOpen?'removeClass':'addClass']('open'); }); }); /* 公用轮播图 */ $(function(){ var intervalTime = 3000, continueTime = 800, index = 0, timeTask; var _length = $('.commonLunBoPic .pic').length - 1; $('.commonLunBoPic .bar li').click(function(){ clearInterval(timeTask); index = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.commonLunBoPic .pic').eq(index).addClass('active').siblings().removeClass('active'); timeTask = setInterval(slideImg, intervalTime); }); //定时器 function slideImg(){ index = index>=_length?0:++index; $('.commonLunBoPic .bar li').eq(index).addClass('active').siblings().removeClass('active'); $('.commonLunBoPic .pic').eq(index).addClass('active').siblings().removeClass('active'); } timeTask = setInterval(slideImg, intervalTime); }); /*新闻页——响应式小导航按钮*/ $(function(){ $('.yidongMenu .menu2 .fa').on('click',function(event){ var isOpen=$(this).closest('.menu2').hasClass('open'); $(this).closest('.menu2')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); $('body').on('click',function(event){ $('.menu2').removeClass('open'); event.stopPropagation(); }); }); $(function(){ $('.yidongMenu .menu1 .fa').on('click',function(event){ var isOpen=$(this).closest('.menu1').hasClass('open'); $(this).closest('.menu1')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); $('body').on('click',function(event){ $('.menu1').removeClass('open'); event.stopPropagation(); }); }); $(function(){ $('.yidongMenupad .menu2 .fa').on('click',function(event){ var isOpen=$(this).closest('.menu2').hasClass('open'); $(this).closest('.menu2')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); $('body').on('click',function(event){ $('.menu2').removeClass('open'); event.stopPropagation(); }); }); $(function(){ $('.yidongMenupad .menu1 .fa').on('click',function(event){ var isOpen=$(this).closest('.menu1').hasClass('open'); $(this).closest('.menu1')[isOpen?'removeClass':'addClass']('open'); event.stopPropagation(); }); $('body').on('click',function(event){ $('.menu1').removeClass('open'); event.stopPropagation(); }); }); //右下角图片滚动 function scroll(p){ var d = document,dd = d.documentElement,db = d.body,w = window,o = d.getElementById(p.id),ie = /msie/i.test(navigator.userAgent),style,timer; if(o){ //ie8下position:fixed下top left失效 o.style.cssText +=";position:"+(p.f&&!ie?'fixed':'absolute')+";"+(p.l==undefined?'right:0;':'left:'+p.l+'px;')+(p.t!=undefined?'top:'+p.t+'px':'bottom:0'); if(p.f&&ie){ o.style.cssText +=';left:expression(body.scrollLeft + '+(p.l==undefined?db.clientWidth-o.offsetWidth:p.l)+' + "px");top:expression(body.scrollTop +'+(p.t==undefined?db.clientHeight-o.offsetHeight:p.t)+'+ "px" );' db.style.cssText +=";background-image:url(about:blank);background-attachment:fixed;" }else{ if(!p.f){ w.onresize = w.onscroll = function(){ clearInterval(timer); timer = setInterval(function(){ var st = db.scrollTop,c; c = st - o.offsetTop + (p.t!=undefined?p.t:(w.innerHeight||db.clientHeight)-o.offsetHeight); if(c!=0){ o.style.top = o.offsetTop + Math.ceil(Math.abs(c)/10)*(c<0?-1:1) + 'px'; }else{ clearInterval(timer); } },10) } } } } } scroll({ id:'aa' }) scroll({ id:'bb', l:0, t:200, f:1 }) /* id 你要滚动的内容的id l 横坐标的位置 不写为紧贴右边 t 你要放在页面的那个位置默认是贴着底边 0是贴着顶边 f 1表示固定 不写或者0表示滚动 */