简体   繁体   English

jQuery循环插件

[英]Jquery Cycle Plugin

I've been using the jquery cycle plugin (malsup.com/jquery/cycle) and it's doing exactly as I want except that it doesn't seem to recognise the first slide as slide one. 我一直在使用jquery cycle插件(malsup.com/jquery/cycle),它的功能完全符合我的要求,只是它似乎无法将第一张幻灯片识别为幻灯片之一。 I'm using the onAfter function to to turn the next/prev links on and off as appropriate and to display page 1 of ? 我正在使用onAfter函数来适当地打开和关闭下一个/上一个链接,并显示第1页? but the next link persists on its own on page 2 (when you would expect the prev link to have appeared) and, although the pages are counted correctly, page 2 shows up as page 1 of 7 same as the real page one). 但是下一个链接将独自保留在第2页上(当您希望上一个链接出现时),并且尽管正确计数了页面,但第2页显示为第1页,共7页,与实际的第1页相同。 You can see what I mean at: 您可以在以下位置看到我的意思:

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

The structure of divs is quite involved but I think it's sound and, as I say, the plugin is counting the divs ok. div的结构相当复杂,但我认为这很合理,正如我所说,该插件可以确定div的数量。

Code below: 代码如下:

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

});

I'd be really grateful for any help with this. 我真的很感谢您对此提供的任何帮助。

Matthew 马修

You are not incrementing currSlide in your after callback. 您不会在after回调中增加currSlide。 Try something like this: 尝试这样的事情:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM