0

I want to use up,down Key to Continue Scrolling i.e if I Press up then Scroll in upward direction or vise versa not one click

Example:

> http://jsfiddle.net/hazim/jLfdf2zh/
Keval Bhatt
  • 6,224
  • 2
  • 24
  • 40

1 Answers1

0

Check out this fiddle: http://jsfiddle.net/jLfdf2zh/2/

//<![CDATA[
$(function () {
    $('#button_up').fadeIn('slow');
    $('#button_down').fadeIn('slow');
    $('#button_down').click(
    function (e) {
        var posY = $('html').scrollTop();
        posY += 300;
        $('html').animate({
            scrollTop: posY
        }, 800);
    });
    $('#button_up').click(
    function (e) {
        var posY = $('html').scrollTop();
        posY -= 300;
        $('html').animate({
            scrollTop: posY
        }, 800);
    });
});
//]]>

UPDATE

http://jsfiddle.net/jLfdf2zh/3/

bernland
  • 688
  • 8
  • 16
  • Fantastic . But Can I make continue scrolling when the button is pressed not to scroll at every click –  May 22 '15 at 08:16
  • This is exactly what you're looking for: http://stackoverflow.com/a/8615582/3337380 – bernland May 22 '15 at 08:40
  • i want like this http://stackoverflow.com/questions/5441975/jcarousel-continue-scrolling-when-at-first-or-last-item-on-button-press?rq=1 –  May 22 '15 at 10:21
  • that is great . thank u bro i try it in google chrome not work but work fine in firefox –  May 22 '15 at 18:51