scroll up and down a div on button click using jquery

前端 未结 7 1428
梦毁少年i
梦毁少年i 2020-12-02 15:14

I am trying to add a feature to scroll up and down a div based on button click. I was able to do the scroll down part easily, but got stuck wit the scroll up part and one mo

相关标签:
7条回答
  • 2020-12-02 15:44

    Where did it come from scrollBottom this is not a valid property it should be scrollTop and this can be positive(+) or negative(-) values to scroll down(+) and up(-), so you can change:

    scrollBottom 
    

    to this scrollTop:

    $("#upClick").on("click", function () {
        scrolled = scrolled - 300;
    
        $(".cover").animate({
            scrollTop: scrolled
        });//^^^^^^^^------------------------------this one
    });
    
    0 讨论(0)
提交回复
热议问题