添加活动滚动页



我想知道如何在每个div 的向下滚动菜单中添加资产

    $(".link").click(function () {
        $('html, body').animate({
            scrollTop: $($.attr(this, 'href')).offset().top
        }, 500);
        return false;
    });

链接:http://jsfiddle.net/r8325qy8/

您可以通过从任何其他元素中删除.current类并将该类添加到单击的目标中来实现这一点。

$(".link").click(function () {
            var target = $(this); // select the current clicked element
            $('html, body').animate({
                scrollTop: $($.attr(this, 'href')).offset().top
            }, 500, function() {
                $('li.current').removeClass('current'); // remove all previous marking
                target.parent().addClass('current'); // apply the css class to the clicked element
            });
            return false;
        });

工作小提琴

最新更新