How to scroll to top of a div using jQuery?

后端 未结 7 1608
耶瑟儿~
耶瑟儿~ 2020-12-23 17:43

I have a gridview inside a div.. I want to scroll to top of the div from the bottom of the div using jquery.. Any suggestion..

//
7条回答
  •  清酒与你
    2020-12-23 18:08

    Here is what you can do using jquery:

    $('#A_ID').click(function (e) { //#A_ID is an example. Use the id of your Anchor
        $('html, body').animate({
            scrollTop: $('#DIV_ID').offset().top - 20 //#DIV_ID is an example. Use the id of your destination on the page
        }, 'slow');
    });
    

提交回复
热议问题