演示代码: Jquery图片展示焦点图 script> $(document).ready(function(){ $imageShow=$('#imageShow'); $images=$('#imageSrc li',$imageShow); $imageSwitches=$('#imageSwitch li',$imageShow); if($images.size()>0){ init(); var timer=setInterval(autoSwitch,3000); $imageSwitches.each(function(index,item){ $(item).click(function(){ clearInterval(timer); setTimeout(function(){timer=setInterval(autoSwitch,3000)},3000); $imageSwitches.css('background-color','').eq(index).css('background-color','#E22E51'); if(index!=$imageShow.data('show')){ $imageShow.data('show',index); $images.hide().eq(index).fadeIn('slow'); } }); }); } function autoSwitch(){ $nowIndex=$imageShow.data('show')+1; if($images.size()>$nowIndex){ $imageSwitches.css('background-color','').eq($nowIndex).css('background-color','#E22E51'); $imageShow.data('show',$nowIndex); $images.hide().eq($nowIndex).fadeIn('slow'); }else{ init(); } } function init(){ $imageShow.data('show',0); $images.hide().eq(0).fadeIn('slow'); $imageSwitches.css('background-color','').eq(0).css('background-color','#E22E51'); } }); script> 1 2 3 4 5 [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]