jQuery - How to scroll an anchor to the top of the page when clicked?

前端 未结 3 501
栀梦
栀梦 2021-01-06 14:39

I have a list of links in div elements and I am using dropcontent.js to load content into another div when a link is clicked. I would now like to a

3条回答
  •  迷失自我
    2021-01-06 15:08

    Here is how you scroll the link to the top:

    $('.work a').click(function() {
         $('html,body').animate({scrollTop: $(this).offset().top}, 500);
    }); 
    

提交回复
热议问题