0

I have a page where I am trying to scroll down a fixed-height DIV (div#main, below div#header and above div#footer), and I've seen several permutations acting on window. However, I don't want to scroll the window; I only want to scroll the DIV.

The present jumble of things I've tried is:

            var scroll_down = function()
                {
                console.log('scrolling...');
                document.getElementById('main').scrollBy(0, 50);
                // document.getElementById('main').scrollBy(0, 50);
                console.log('scrolling... 2');
                /*
                jQuery('#main').animate({'scrollTop':
                  jQuery('#main').height() +
                  jQuery('#header').height()});
                  */
                console.log('scrolling... 3');
                }

The first approach looks like document.getElementById() is returning null or undefined; neither has moved the page.

How, with or without jQuery, should I be saying, "Please scroll down div#main all the way"?

Thanks,

Christos Hayward
  • 5,777
  • 17
  • 58
  • 113
  • 1
    have you seen this thread about doing this with jquery? http://stackoverflow.com/questions/10503606/scroll-to-bottom-of-div-on-page-load-jquery – roastbeef Aug 04 '14 at 19:41
  • Thank you, @roastbeef; I had spent a while searching but not found that specific one. Now my webpage is just as desired. – Christos Hayward Aug 04 '14 at 19:48

0 Answers0