//jquery滚动 (function($){ $.fn.kxbdMarquee = function(options){ var opts = $.extend({},$.fn.kxbdMarquee.defaults, options); return this.each(function(){ var $marquee = $(this);//滚动元素容器 var _scrollObj = $marquee.get(0);//滚动元素容器DOM var scrollW = $marquee.width();//滚动元素容器的宽度 var scrollH = $marquee.height();//滚动元素容器的高度 var $element = $marquee.children(); //滚动元素 var $kids = $element.children();//滚动子元素 var scrollSize=0;//滚动元素尺寸 var _type = (opts.direction == 'left' || opts.direction == 'right') ? 1:0;//滚动类型,1左右,0上下 //防止滚动子元素比滚动元素宽而取不到实际滚动子元素宽度 $element.css(_type?'width':'height',10000); //获取滚动元素的尺寸 if (opts.isEqual) { scrollSize = $kids[_type?'outerWidth':'outerHeight']() * $kids.length; }else{ $kids.each(function(){ scrollSize += $(this)[_type?'outerWidth':'outerHeight'](); }); } //滚动元素总尺寸小于容器尺寸,不滚动 if (scrollSize<(_type?scrollW:scrollH)) return; //克隆滚动子元素将其插入到滚动元素后,并设定滚动元素宽度 $element.append($kids.clone()).css(_type?'width':'height',scrollSize*2); var numMoved = 0; function scrollFunc(){ var _dir = (opts.direction == 'left' || opts.direction == 'right') ? 'scrollLeft':'scrollTop'; if (opts.loop > 0) { numMoved+=opts.scrollAmount; if(numMoved>scrollSize*opts.loop){ _scrollObj[_dir] = 0; return clearInterval(moveId); } } if(opts.direction == 'left' || opts.direction == 'up'){ var newPos = _scrollObj[_dir] + opts.scrollAmount; if(newPos>=scrollSize){ newPos -= scrollSize; } _scrollObj[_dir] = newPos; }else{ var newPos = _scrollObj[_dir] - opts.scrollAmount; if(newPos<=0){ newPos += scrollSize; } _scrollObj[_dir] = newPos; } }; //滚动开始 var moveId = setInterval(scrollFunc, opts.scrollDelay); //鼠标划过停止滚动 $marquee.hover( function(){ clearInterval(moveId); }, function(){ clearInterval(moveId); moveId = setInterval(scrollFunc, opts.scrollDelay); } ); //控制加速运动 if(opts.controlBtn){ $.each(opts.controlBtn, function(i,val){ $(val).bind(opts.eventA,function(){ opts.direction = i; opts.oldAmount = opts.scrollAmount; opts.scrollAmount = opts.newAmount; }).bind(opts.eventB,function(){ opts.scrollAmount = opts.oldAmount; }); }); } }); }; $.fn.kxbdMarquee.defaults = { isEqual:true,//所有滚动的元素长宽是否相等,true,false loop: 0,//循环滚动次数,0时无限 direction: 'left',//滚动方向,'left','right','up','down' scrollAmount:1,//步长 scrollDelay:10,//时长 newAmount:3,//加速滚动的步长 eventA:'mousedown',//鼠标事件,加速 eventB:'mouseup'//鼠标事件,原速 }; $.fn.kxbdMarquee.setDefaults = function(settings) { $.extend( $.fn.kxbdMarquee.defaults, settings ); }; })(jQuery); $(document).ready(function(){ /*索引漂浮代码*/ var window_width = $(window).width(); var nav_left = window_width/2+510; //自定义*漂浮层距离页面左边的初始宽度 var nav_top = 550; //自定义*漂浮层距离页面顶部的初始高度 var s_top = 350; //自定义*页面滚动超过该高度后漂浮层开始滚动 var scrollheight; //定义滚动条高度 $("#index_float_nav").css("left",nav_left); //定位初始宽度 $("#index_float_nav").css("top",nav_top); //定位初始高度 $(window).scroll(function(){ //当滚动条滚动时触发 scrollheight = $(document).scrollTop(); //计算滚动条的偏移 if (scrollheight>=s_top){ $("#index_float_nav").css("top",scrollheight+nav_top-s_top); //重新定位top } }); $(window).resize(function(){ //当窗口改变时执行,使漂浮条自动适应窗口宽度 window_width = $(window).width(); nav_left = window_width/2+510; $("#index_float_nav").css("left",nav_left); }); $("#index_float_nav ul li a").click(function(){ //漂浮条索引ul li点击事件 $(this).parent().parent().children().css("background-image","url(http://www.gykxt.com/images/float_nav_n.png)"); //将所有li的背景图替换为+号 $(this).parent().css("background-image","url(http://www.gykxt.com/images/float_nav_y.png)"); //将选中的li的背景图替换为-号 }); /*导航条代码*/ $('#index_navbar .Toolbar1 .Menu ul li').mouseenter(function () { var index = $(this).parent().children().index(this); $(this).parent().children().each(function () { if ($(this).hasClass('Select')) { $(this).removeClass('Select'); } }); $(this).addClass('Select'); $('#index_navbar .Toolbar2 .Menu').each(function () { if (!$(this).hasClass('Hide')) { $(this).addClass('Hide'); } }); $('#index_navbar .Toolbar2 .Menu').eq(index).removeClass('Hide'); }); /*活动资讯切换代码*/ $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_control div').click(function () { var i = $(this).parent().children().index(this); if(i<=1){ $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_boxs .Hdzx_box').hide(); $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_boxs .Hdzx_box').eq(0).show(); $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_control').css("background-image","url(http://www.gykxt.com/images/hdzx_control_back1.jpg)"); $("#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_boxs .Hdzx_box div").eq(0).trigger("click") } else{ $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_boxs .Hdzx_box').hide(); $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_boxs .Hdzx_box').eq(1).show(); $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_control').css("background-image","url(http://www.gykxt.com/images/hdzx_control_back2.jpg)"); $("#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_boxs .Hdzx_box div").eq(4).trigger("click") } }); $('#hdzx_1 #hdzx_tabbox #hdzx_title #hdzx_boxs .Hdzx_box div').click(function () { $(this).parent().children().each(function () { if ($(this).hasClass('Select')) { $(this).removeClass('Select'); } }); $(this).addClass('Select'); var i = $(this).attr("at"); if(i==0||i==4){ $('#hdzx_1 #hdzx_tabbox #hdzx_title').css("background-image","url(http://www.gykxt.com/images/hdzx_title1.jpg)"); } else if(i==1||i==5){ $('#hdzx_1 #hdzx_tabbox #hdzx_title').css("background-image","url(http://www.gykxt.com/images/hdzx_title2.jpg)"); } else if(i==2||i==6){ $('#hdzx_1 #hdzx_tabbox #hdzx_title').css("background-image","url(http://www.gykxt.com/images/hdzx_title3.jpg)"); } else if(i==3||i==7){ $('#hdzx_1 #hdzx_tabbox #hdzx_title').css("background-image","url(http://www.gykxt.com/images/hdzx_title4.jpg)"); } $('#hdzx_1 #hdzx_tabs div').hide(); $('#hdzx_1 #hdzx_tabs div').eq(i).show(); }); /*日期获取代码*/ setInterval(showTime, 1000); function timer(obj,txt){ obj.text(txt); } function showTime(){ var today = new Date(); var weekday=new Array(7) weekday[0]="星期日" weekday[1]="星期一" weekday[2]="星期二" weekday[3]="星期三" weekday[4]="星期四" weekday[5]="星期五" weekday[6]="星期六" var week=weekday[today.getDay()]; var month=today.getMonth()+1; var day=today.getDate(); timer($("#date_week"),week); timer($("#date_month"),month); timer($("#date_day"),day); } /*行大典6图js*/ $(".section_1 ul li .rsp").hide(); $(".section_1 ul li").hover(function(){ $(this).find(".rsp").stop().fadeTo(500,0.5) $(this).find(".text").stop().animate({left:'0'}, {duration: 500}) },function(){ $(this).find(".rsp").stop().fadeTo(500,0) $(this).find(".text").stop().animate({left:'318'}, {duration: "fast"}) $(this).find(".text").animate({left:'-318'}, {duration: 0}) }); $(".section_2 ul li .rsp").hide(); $(".section_2 ul li").hover(function(){ $(this).find(".rsp").stop().fadeTo(500,0.5) $(this).find(".text").stop().animate({left:'0'}, {duration: 500}) },function(){ $(this).find(".rsp").stop().fadeTo(500,0) $(this).find(".text").stop().animate({left:'318'}, {duration: "fast"}) $(this).find(".text").animate({left:'-318'}, {duration: 0}) }); $(".section_3 ul li .rsp").hide(); $(".section_3 ul li").hover(function(){ $(this).find(".rsp").stop().fadeTo(500,0.5) $(this).find(".text").stop().animate({left:'0'}, {duration: 500}) },function(){ $(this).find(".rsp").stop().fadeTo(500,0) $(this).find(".text").stop().animate({left:'318'}, {duration: "fast"}) $(this).find(".text").animate({left:'-318'}, {duration: 0}) }); $(".section_4 ul li .rsp").hide(); $(".section_4 ul li").hover(function(){ $(this).find(".rsp").stop().fadeTo(500,0.5) $(this).find(".text").stop().animate({left:'0'}, {duration: 500}) },function(){ $(this).find(".rsp").stop().fadeTo(500,0) $(this).find(".text").stop().animate({left:'318'}, {duration: "fast"}) $(this).find(".text").animate({left:'-318'}, {duration: 0}) }); $(".section_5 ul li .rsp").hide(); $(".section_5 ul li").hover(function(){ $(this).find(".rsp").stop().fadeTo(500,0.5) $(this).find(".text").stop().animate({left:'0'}, {duration: 500}) },function(){ $(this).find(".rsp").stop().fadeTo(500,0) $(this).find(".text").stop().animate({left:'318'}, {duration: "fast"}) $(this).find(".text").animate({left:'-318'}, {duration: 0}) }); $(".section_6 ul li .rsp").hide(); $(".section_6 ul li").hover(function(){ $(this).find(".rsp").stop().fadeTo(500,0.5) $(this).find(".text").stop().animate({left:'0'}, {duration: 500}) },function(){ $(this).find(".rsp").stop().fadeTo(500,0) $(this).find(".text").stop().animate({left:'318'}, {duration: "fast"}) $(this).find(".text").animate({left:'-318'}, {duration: 0}) }); /*jquery滚动实例*/ $('.marquee').kxbdMarquee({ direction:'left', eventA:'mouseenter', eventB:'mouseleave' }); $(function() { var page = 1; var i = 1; var conheight = $('.con').height(); var lilen = $(".con_list .menu").length; var len = Math.ceil( lilen / i ); $('.next_xgx').click(function() { if( page == len ) { page = len; }else{ $('.con_list').animate({top:'-=' + conheight},'slow'); page++; } }); $('.prev_xgx').click(function() { if( page == 1 ) { }else{ $('.con_list').animate({top:'+=' + conheight},'slow'); page--; } }); }) });