基于jQuery的楼层案例

~(function() {
            var flag = true;

            //点击切换效果
            $(".oDR7_asideItem:not(:first)").click(function() {
                flag = false;
                //alert($(".oRD8_stairs").length);
                $(".oDR7_asideItem").removeClass("oDR7_active").find("span").removeClass("oDR7_activeDot").removeClass("oDR7_color");
                $(this).addClass("oDR7_active").find("span:nth-of-type(2)").addClass("oDR7_activeDot").end().find("span:last-of-type").addClass("oDR7_color");
                var sTop = $(".oRD8_stairs").eq($(this).index()-1).offset().top - 165;
                $("body,html").animate({
                    "scrollTop": sTop
                }, 1000, function() {
                    flag = true;
                });
            });

            //滚动条滚动效果
            $(window).scroll(function() {
                if (flag) {
                    var sTop = $(document).scrollTop();
                    //alert($(".oRD8_stairs2").length);
                    var $floor = $(".oRD8_stairs2").filter(function(index, ele) {
                        return Math.abs($(this).offset().top - sTop) < $(this).height() / 2;
                    });
                    if($floor.index()-1 > 0) {
                        $(".oDR7_asideItem").removeClass("oDR7_active").find("span").removeClass("oDR7_activeDot").removeClass("oDR7_color");
                        $(".oRD7_stairs2List").eq($floor.index()-1).addClass("oDR7_active").find("span:nth-of-type(2)").addClass("oDR7_activeDot").end().find("span:last-of-type").addClass("oDR7_color");
                    }
                }
            });

            //悬浮效果
            $(".oDR7_asideItem:not(:first)").hover(function() {
                $(".oDR7_asideItem").removeClass("oDR7_active").find("span").removeClass("oDR7_activeDot").removeClass("oDR7_color");
                $(this).addClass("oDR7_active").find("span:nth-of-type(2)").addClass("oDR7_activeDot").end().find("span:last-of-type").addClass("oDR7_color");
            },function() {});
        })();

 

转载于:https://www.cnblogs.com/intelwisd/p/7521479.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值