Jquery 循环插件
我一直在使用 jquery 循环插件 (malsup.com/jquery/cycle),它的表现完全符合我的要求,只是它似乎没有将第一张幻灯片识别为第一张幻灯片。我使用 onAfter 函数来根据需要打开和关闭下一个/上一个链接,并 显示 ? 的第 1 页但下一个链接仍然保留在第 2 页上 (当您期望上一个链接出现时)并且,尽管 页数计数正确,第 2 页显示为第 1 页(共 7 页)相同 作为真实的页面之一)。您可以在以下位置明白我的意思:
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);
}
});
如果您对此提供任何帮助,我将非常感激。
马修
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. I'm using the onAfter function to to turn the next/prev links on and off as appropriate and to
display page 1 of ? 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). You can see what I mean at:
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.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有在回调后增加 currSlide 。尝试这样的事情:
You are not incrementing currSlide in your after callback. Try something like this: