jQuery楼层定位菜单代码是一款商城常用的点击侧边楼层或者鼠标滚轮滚动都能精确定位到页面对应的楼层位置的折叠式楼层菜单网页特效。
js代码
<script src="https://img.x22t.com/file/2020/04/25/d54226788bf9c0c12e56225e6777e29d7174.js"></script> <script> $(function(){ $("li:odd").hide();//li的第偶数个隐藏 $("#slider ul li.active").next().show();//激活的li下面那条线显示 $(window).scroll(function(){ var winHeight = $(window).height();//浏览器可视窗口的高度 var scrollHeight = $(window).scrollTop();//鼠标滚动的距离 // if($("#header").height()){ //判断侧边栏什么时候显示 $("#content .section").each(function(){ if(winHeight+scrollHeight-$(this).offset().top>winHeight/2){ $("#slider ul li").removeClass("active").prev(".line").hide(); $("#slider ul li").eq($(this).index()).addClass("active").next(".line").show(); } }) // } }) $("#slider ul li").click(function(){ var current = $("#content .div").eq($(this).index()).offset().top; $("html,body").animate({ "scrollTop":current },500); $(this).addClass("active").siblings().removeClass("active").siblings(".line").hide(); $(this).eq($(this).index()).addClass("active").next(".line").show(); }) }) </script>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)