How do i make a scrolling div always start at the top?

hello,

how do i make a scrolling div always start at the top ?

i have used the code from this post :

http://www.sitepoint.com/forums/showthread.php?727088-Jquery-scroll-some-text-inside-a-div-with-overflow

i works great but when i refresh the page it does not go back to the top of the div (the latest post)

this is the code :




 <!-- HOME HOME TWITTER SCROLL UP / DOWN -->
	$(function() {
    var ele   = $('#scroll');
    var speed = 50, scroll = 5, scrolling;

    $('#sw-up').mouseenter(function() {
        // Scroll the element up
        scrolling = window.setInterval(function() {
            ele.scrollTop( ele.scrollTop() - scroll );
        }, speed);
    });

    $('#sw-down').mouseenter(function() {
        // Scroll the element down
        scrolling = window.setInterval(function() {
            ele.scrollTop( ele.scrollTop() + scroll );
        }, speed);
    });

    $('#sw-up, #sw-down').bind({
        click: function(e) {
            // Prevent the default click action
            e.preventDefault();
        },
        mouseleave: function() {
            if (scrolling) {
                window.clearInterval(scrolling);
                scrolling = false;
            }
        }
    });
});	
	

thanks
ricky

Hi,

The code should do that automatically, that is to say that there is nothing in the code you posted which would cause the behaviour you describe.

Could you therefore post a bit more code so that I can recreate your problem and/or a link to your page.

In the worst case you can just set scrollTop of the appropriate div to zero on page load.