2013-05-20 45 views
0

我最近做了這個教程:http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/我想知道是否有人知道如何使用本教程中的代碼,但將其更改爲在點擊文本時自動滾動瀏覽圖像而不是滾動瀏覽。如何自動執行此幻燈片的代碼?

在檢查後鼠標滾動圖片代碼「點擊」事件是:

$(theImage).each(  
function(intIndex){    
$(this).nextAll('a') 
.bind("click", function(){ 
    if($(this).is(".next")) { 
     $(this).parent('li').parent('ul').animate({ 
      "margin-left": (-(intIndex + 1) * theWidth)    
       }, 1000)  
     } else if($(this).is(".previous")){ 
     $(this).parent('li').parent('ul').animate({ 
      "margin-left": (-(intIndex - 1) * theWidth)    
     }, 1000)  
     } else if($(this).is(".startover")){ 
     $(this).parent('li').parent('ul').animate({ 
      "margin-left": (0)    
     }, 1000) 
} 
});//close .bind()         
});//close .each() 

聲明:

.bind("click", function(){... 

檢查鼠標「點擊」事件,然後執行,如果聲明。我希望在不首先點擊的情況下運行if語句。任何幫助將不勝感激,謝謝。

回答

0
<script language="JavaScript" type="text/javascript"> 
var images = new Array('morning.jpg','afternoon.jpg','night.jpg','lightbulb_on.jpg') 
var count = -1 

function slideShow(){  

if (count <=2){  
    count ++; 
} 

    document.getElementById("show").innerHTML = "<img src="images/"+images[count]+"">" 
    setTimeout("slideShow()", 3000)  
}  
</script> 
<div id="show"> 
<script>slideShow()</script> 
</div> 

這個工程與點擊事件,所以你必須改變它的工作方式,設置計時器。 我通常用這段代碼來做。希望能幫助到你。 我不會把評論,因爲我不能(低信譽)對不起