如何重新启动jQuery幻灯片

问题描述:

我有以下代码。单击我想要更改为暂停滑块并将图像更改为暂停。此代码暂停幻灯片显示但不重新启动。它也不会切换图像。如何重新启动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" }); 
      } 
     ); 
    }); 

}); 

试试这个:

$('#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" }); 
     } 
    ); 
});