如何重新启动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" });
      }
    );
});

最新更新