jQuery scroll a div up and down using two buttons

后端 未结 4 2208
执念已碎
执念已碎 2021-02-10 13:45

I have a simple set of two buttons that when hovered should make a div move up and down to simulate a scrolling effect:

$(\"#down\").hover(function () {

    $(\         


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-02-10 14:27

    1. You'll need to set the animations parameter to the divs actual height jQuery .height() method

    2. You should change your mouse events bindings on "mouseenter" and "mouseleave" and then with "mouseleave" you can stop a jQuery element animation with the jQuery .stop() method

    3. You can calculate this with the jQuery .height() method too.

提交回复
热议问题