I'm new to jQuery and I'm just wondering the easiest and most efficient way to create next/previous buttons to go through the slideshow. My code is as follows:
run = setInterval("switchSlide()", 2000); $(document).ready(function() { $('#slideshow img:gt(0)').hide(); $('#slideshow').hover(function() { clearInterval(run); }, function() { run = setInterval("switchSlide()", 2000); }); $('#play').click(function() { run = setInterval("switchSlide()", 2000); }); $('#stop').click(function() { clearInterval(run); }); $('#previous').click(function() { $('#slideshow img:first').fadeOut(1000).prev().fadeIn(1000).end().appendTo('#slideshow'); }); $('#next').click(function() { $('#slideshow img:first').fadeOut(1000).next().fadeIn(1000).end().appendTo('#slideshow'); }); }); function switchSlide() { $('#slideshow img:first').fadeOut(1000).next().fadeIn(1000).end().appendTo('#slideshow'); }