Darren
Darren

Reputation: 793

Constantly scroll text up within a div

I need a very simple jQuery to constantly scroll a list of text items up without using a plugin. I know this is probably fairly simple but I can't find an example that I can use and I have already spent too much time on it at work.

No parameters will need to be changed by mouse hover or button click, so everything can be ran within document.ready and never touched again. My only request is that, ideally, it should be constantly looped.

Upvotes: 0

Views: 2947

Answers (3)

Michael Sparks
Michael Sparks

Reputation: 645

wrote a jquery plugin for this just now.

$('.scrolling-div').rollup({speed:2000});

http://jsfiddle.net/hmPPe/5/

Upvotes: 2

Supr
Supr

Reputation: 19022

In short:

function cycle($item, $cycler){
    setTimeout(cycle, 2000, $item.next(), $cycler);

    $item.slideUp(1000,function(){
        $item.appendTo($cycler).show();        
    });

}

cycle($('#cycler div:first'),  $('#cycler'));

With #cycler being the container with the divs that are to be cycled. See demo.

Upvotes: 4

Blazemonger
Blazemonger

Reputation: 92893

Basic code that will work, but stops at the bottom:

setInterval(function() {
    var $c = $('#container');
        $c.scrollTop($c.scrollTop() + 1)
}, 100);​

http://jsfiddle.net/55AY2/

I'm not sure what you mean by "constantly looped".

Upvotes: 1

Related Questions