2013-12-15 40 views
0

我有簡單的幻燈片jQuery代碼。 我希望當顯示最後img然後顯示一些警報或做一些事情。當幻燈片顯示最後的圖像,然後顯示警報

<script> 
    $(document).ready(function() 
    { 
    $('.img:gt(0)').hide(); 
    setInterval(function() { 
     $(".img:first-child").fadeOut(3000).next(".img").fadeIn(3000).end().appendTo("#show-case") 
    }, 4000); 
    }); 
</script> 
+0

嗨!歡迎來到stackoverflow。請制定一個明確的問題和你遇到的錯誤。 – Stefan

回答

0

嘗試,

$(document).ready(function() 
{ 
    $('.img:gt(0)').hide(); 

    setInterval(
     function() { 
     $(".img:first-child") 
     .fadeOut(3000) 
     .next(".img") 
     .fadeIn(3000).end().appendTo("#show-case"); 

     if($('.img').length - $('#show-case .img').length == 0) 
     { 
       alert("last image..!") 
     } 

     }, 4000); 
}); 
+0

不起作用。此代碼在每個img後顯示警報。 – user3104879

+0

@ user3104879你可以創建一個演示。或者只顯示你的html的結構。 –

+0

http://jsfiddle.net/52nxL/ – user3104879