Hi everyone, how do I make this jquery script loop continously? At the moment it only makes the changes once. The code is shown below. HTML: <body onload='next();'> <p class='active'> This is a test </p> <p> This is a test </p> <p> This is a test </p> </body> Code (markup): CSS: .active { background:red; } .bg { background:yellow; } Code (markup): Jquery: function slide(){ $(document).ready(function(){ var t = $("p:first"); t.removeClass('active'); t.next().addClass('bg'); }); }; function next(){ setInterval('slide()', 1000); }; Code (markup): Thank You
try this HTML: <body onload='slide();'> <p class='active'> This is a test </p> <p> This is a test </p> <p> This is a test </p> </body> Code (markup): CSS: .active { background:red; } .bg { background:yellow; } Code (markup): Jquery: function slide(){ $(document).ready(function(){ var t = $("p:first"); t.removeClass('active'); t.next().addClass('bg'); setTimeout('slide()',1000); }); }; Code (markup):