Smooth scroll to specific div on click

后端 未结 7 1470
抹茶落季
抹茶落季 2020-11-28 02:36

What I\'m trying to do is make it so that if you click on a button, it scrolls down (smoothly) to a specific div on the page.

What I need is if you click on the butt

7条回答
  •  佛祖请我去吃肉
    2020-11-28 02:39

    do:

    $("button").click(function() {
        $('html,body').animate({
            scrollTop: $(".second").offset().top},
            'slow');
    });
    

    Updated Jsfiddle

提交回复
热议问题