私はjQueryを初めて使用しますが、スライドショーを実行するための次/前のボタンを作成するための最も簡単で効率的な方法を考えています。私のコードは次のとおりです。
run = setInterval( "switchSlide()"、2000); $(document).ready(function(){ $('#slideshow img:gt(0)')。hide(); $('#slideshow')。hover(function(){ clearInterval(run); }、 働き() { 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'); }); }); 関数switchSlide(){ $('#slideshow img:first')。fadeOut(1000).next()。fadeIn(1000).end()。appendTo('#slideshow'); }