treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Multiple Fading Headlines with jQuery

  • Hi folks,

    I'm using this clever script from http://www.subchild.com/2008/08/02/creating-fading-headlines-in-5-minutes-with-jquery/

    But am unsure of how to have two different fading lists on the same page:

    $(document).ready(function(){
    $("#headlines li").hide();

    var headlineFadeSpeed = 5000;
    function showNextItem(){
    var index = arguments[0] || 1;
    var $curLi = $("#headlines li:nth-child("+index+")");
    var totalItems = $("#headlines li").length;

    $curLi.fadeIn("fast", function(){
    setTimeout(function(){
    $curLi.fadeOut("slow", function(){
    index = (index < totalItems) ? index+1 : 1;
    showNextItem(index);
    });
    }, headlineFadeSpeed);
    });
    }

    showNextItem();
    });


    Can anyone help?
  • call it on a different element other than #headlines li?