tags:

views:

118

answers:

5

I have a div and I would like to auto scroll it every 5 seconds, can I do that with JQuery?

A: 

Check out the scrollTop() function...

http://api.jquery.com/scrollTop/

Lunchy
http://demo.webdesignbooth.com/content-slider/im looking for something like that but without the clickable tabs, I want it to be automatic
vick
A: 

Based on your comment with the demo link, you probably want the Cycle plug-in then: http://jquery.malsup.com/cycle/

Yes it will work with any tags, not just images. If you want to cycle through several <div> tags you could do something like so:

<div class="slideshow">
    <div>Test 1</div>
    <div>Test 2</div>
    <div>Test 3</div>
</div>

It will cycle through any tags within the slideshow class.

Erikk Ross
A: 

There is coda slider plugin which is quite similar.

http://www.ndoherty.biz/demos/coda-slider/2.0/

And there is this tutorial for a custom one if you want to create your own,

http://jqueryfordesigners.com/coda-slider-effect/

Hope these helps, Sinan.

Sinan Y.
A: 
<!doctype html>
<html>
<head>
<title>JQuery Cycle Plugin - Example Slideshow</title>
<style type="text/css">
.slideshow { height: 232px; width: 232px; margin: auto }
.slideshow img { padding: 15px; border: 1px solid #ccc; background-color: #eee; }
</style>
<!-- include jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"&gt;&lt;/script&gt;

<!-- include Cycle plugin -->
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.74.js"&gt;&lt;/script&gt;

<!--  initialize the slideshow when the DOM is ready -->
<script type="text/javascript">
$(document).ready(function() {
    $('.slideshow').cycle({
        fx: 'shuffle' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
});
</script>
</head>
<body>
    <div class="slideshow">
        <img src="http://cloud.github.com/downloads/malsup/cycle/beach1.jpg" width="200" height="200" />
        <img src="http://cloud.github.com/downloads/malsup/cycle/beach2.jpg" width="200" height="200" />
        <img src="http://cloud.github.com/downloads/malsup/cycle/beach3.jpg" width="200" height="200" />
    </div>
</body>
</html>

that is exacly what I want, but I want it to work with tags instead of images...can I modify it to work?

vick
Yes, see my modified answer.
Erikk Ross
A: 
var scrolling = window.setInterval("autoScroll()", 5000);

function autoScroll(elem) {

    $(function() {
        $('div#mycontainer').animate({ scrollTop: '+=' + 40 });
    });

}
XGreen