Shyju Shyju - 3 months ago 8
Javascript Question

Auto Slider / Scroller to display dynamic content

Can any one tell me how can i implement a auto slider/scroller in my web page. The slider should show dynamic data from a database. (Ex : Hot jobs tab in the site's home page ( . Is there any easy way to do this with jQuery ?


The following is nothing special, just quickly tried it. There's 2 div's that it continously switches between, hopefully give you a head start. You could use the same idea and load content into div's via AJAX.

Code snippet:


#container{overflow:hidden;border:1px solid black;}


$(function() {
        //Call scrollContent function every 3secs
    var timerUp = setInterval(scrollContent, 3000);

    function scrollContent(){
        //Toggle top between 100 and 0
        var top = $("#container").scrollTop() == 0 ? 100 : 0;


<div id="container">
        <div id="left">
        <div id="right">