0

我一直在使用 jquery 循环插件 (malsup.com/jquery/cycle),它完全按照我的意愿进行操作,只是它似乎没有将第一张幻灯片识别为第一张幻灯片。我正在使用 onAfter 函数来适当地打开和关闭下一个/上一个链接并显示第 1 页?但是下一个链接会在第 2 页上自行保留(当您希望出现上一个链接时),虽然页面计数正确,但第 2 页显示为第 1 页,共 7 页,与实际第 1 页相同)。你可以看到我的意思:

http://www.nottingham.ac.uk/~ttzelrn/ma-tesol/module1/unit1/index.php

div 的结构非常复杂,但我认为它是合理的,正如我所说,插件正在计算 div 好。

下面的代码:

$(document).ready(function() {
      $('#cycle-content').cycle({
      fx:     'none',
      prev:   '#prev',
      next:   '#next',
      after:   onAfter,
      timeout: 0
      });

function onAfter(curr, next, opts) {
var index = opts.currSlide;
$('#prev')[index == 0 ? 'hide' : 'show']();
$('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();

var caption = 'Page ' + (opts.currSlide + 1) + ' of ' +
opts.slideCount;
$('#caption').html(caption);
}

});

对于这方面的任何帮助,我将不胜感激。

马修

4

1 回答 1

1

您没有在 after 回调中增加 currSlide 。尝试这样的事情:

$(document).ready(function() {
      $('#cycle-content').cycle({
      fx:     'none',
      prev:   '#prev',
      next:   '#next',
      after:   onAfter,
      timeout: 0
      });
});

function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    $('#prev')[index == 0 ? 'hide' : 'show']();
    $('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
    opts.currSlide++;
    var caption = 'Page ' + (opts.currSlide) + ' of ' + opts.slideCount;
    $('#caption').html(caption);
}
于 2009-11-14T13:12:39.907 回答