您好,欢迎访问一九零五行业门户网

jquery编写Tab选项卡滚动导航切换特效_jquery

本文实例为大家分享jquery编写tab选项卡切换特效,供大家参考,具体内容如下
效果说明:点击tab导航,页面滑动到下方相应板块。并且当页面通过鼠标滚动下去时,上方的tab也可以自动切换到当前位置的板块上。
代码说明:js中对两个动作分别写,一个是tab点击下滑到相应板块位置;一个是鼠标滚动下去的时候tab判定当前页面滚动高度切换tab。
js:
$(document).ready(function(){ $('.switch-tab>li').click(function(){ var s=$('.switch-tab>li').index(this); $('body,html').animate({scrolltop:$('.tab-content>.tab-panel:eq('+s+')').offset().top-50},200); }); var dt=$('.switch-tab').offset().top; $(window).scroll(function(){ var wt=$(window).scrolltop(),l=$('.tab-content>.tab-panel'),s=l.length-1; if(wt=l.last().offset().top+l.last().height()+50){ $('.switch-tab').removeclass('fixed'); $('.switch-tab>li:first').addclass('active').siblings().removeclass('active'); }else{ $('.switch-tab').addclass('fixed'); for(var i=0;i=parseint(l.eq(i).offset().top-50)&&wtli:eq('+s+')').addclass('active').siblings().removeclass('active'); } });});
html:
拉托红酒 法国酒庄风情 红酒包装 个性定制
1111
222
333
444

以上就是本文的全部内容,希望对大家的学习有所帮助。
其它类似信息

推荐信息