开发者

jquery: hover button for controlling a div's scrollbar?

开发者 https://www.devze.com 2023-03-24 07:56 出处:网络
i\'m having a div with lots of content and a vertical scrollbar. i\'d like to replace the scrollbar with an up/down button in order to scroll the开发者_C百科 content on hovering the buttons.

i'm having a div with lots of content and a vertical scrollbar. i'd like to replace the scrollbar with an up/down button in order to scroll the开发者_C百科 content on hovering the buttons. any ideas how to do this? thanks


Try scrollTop()

var timeoutId = 0;

function scrollIt(amount){
    $('div').scrollTop($('div').scrollTop()+amount);
}

$('.down').mousedown(function() {
    timeoutId = setTimeout(scrollIt(5), 1000);
}).bind('mouseup mouseleave', function() {
    clearTimeout(timeoutId);
});

$('.up').mousedown(function() {
    timeoutId = setTimeout(scrollIt(-5), 1000);
}).bind('mouseup mouseleave', function() {
    clearTimeout(timeoutId);
});


I think this plugin might be helpful: http://www.kelvinluck.com/assets/jquery/jScrollPane/jScrollPane.html


I think based on this, you'll get a pretty good start on how to do this.

http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12

0

精彩评论

暂无评论...
验证码 换一张
取 消