/** * 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 += "