/** * tabs * @author lzf */ function tabs(tabTitle,tab_content){ var index=$(tabTitle).children(".hover").index() $(tab_content).children().eq(index).show().siblings().hide(); $(tabTitle).children().click(function(){ var index=$(this).index(); $(this).addClass("hover").siblings().removeClass("hover"); $(tab_content).children().eq(index).show().siblings().hide(); return false; }); } /** * scrollFix * @author lzf */ function scrollFixed(obj1,obj2,obj3){ // obj1 为子集的标签 // obj2 为顶部外层的盒子 // obj3 为底部滑动到位置的盒子的class,不是包含所有盒子的外层 var arr1 = []; var i = 0; var md = $(obj1); //获取下面对应的每块内容距离顶部的距离,放在一个数组里面 $(window).load(function(){ $(obj3).each(function(){ var pos = $(this).offset().top; arr1.push(pos); }) }) var navOffsetTop=$(obj2).offset().top; var navOffsetH=$(obj2).innerHeight(); //上边小按钮的点击事件 md.each(function(num,val){ $(md[num]).click(function(){ $("html,body").stop(true,true).animate({scrollTop:(arr1[num]-navOffsetH-80)+"px"}, 600); //update(); }) }); function update(){ var scrollH = $(window).scrollTop(); //滚动顶部固定 if(scrollH>navOffsetTop+90){ $(obj2).css({"position":"fixed","top":"90px"}) }else{ $(obj2).css({"position":"relative","top":"auto"}) } //滚动导航高亮切换 for(var num =0; num\n"; strVar += "<\/div>\n"; strVar += "
\n"; strVar += "
\n"; strVar += "