2011-05-02 69 views
0

我有以下代碼。單擊我想要更改爲暫停滑塊並將圖像更改爲暫停。此代碼暫停幻燈片顯示但不重新啓動。它也不會切換圖像。如何重新啓動jQuery幻燈片

$(document).ready(function() { 
    $("#nextbackcontrols").show(); 
    $('.slideshow').cycle({ 
     fx: 'fade', 
     prev: '#prev', 
     next: '#next' 
    }); 

    $('#play').click(function() { 
     $('.slideshow').cycle('toggle'); 
     $("#play img").toggle(
      function() { 
       $(this).find("img").attr({ src: "/common/images/play.gif" }); 
      }, 
      function() { 
       $(this).find("img").attr({ src: "/common/images/pause.gif" }); 
      } 
     ); 
    }); 

}); 

回答

1

試試這個:

$('#play').live("click", function() { 
    $('.slideshow').cycle('toggle'); 
    $("#play img").toggle(
     function() { 

      // previously you were `.find`ing an image within an image 
      $(this).attr({ src: "/common/images/play.gif" }); 
     }, 
     function() { 
      $(this).attr({ src: "/common/images/pause.gif" }); 
     } 
    ); 
});