【问题标题】:jQuery cycle pagerjQuery 循环寻呼机
【发布时间】:2012-01-06 09:36:13
【问题描述】:

我让这个寻呼机工作了:http://jquery.malsup.com/cycle/pager6.html 但是,如果我在一页上有多个幻灯片并且我不想为寻呼机使用 ID 怎么办。 但是使用 X 类最近的元素作为寻呼机。

这个可以吗?

这是我当前的代码:

$(document).ready(function()
{
    $('.photoGallerySlideshowAlbum').cycle(
    {
        fx: 'fade',
        pager: '#photoGallerySlideshowPager',
        activePagerClass: 'selected',
        pagerAnchorBuilder: function(idx, slide)
        { 
            return '#photoGallerySlideshowPager li:eq(' + idx + ') a';
        },
        after: function(currentImage, nextImage, options)
        {
            var captions = $(this).parent().parent().find('.photoGallerySlideshowCaptions').children().hide();
            var caption = $(captions[options.currSlide]);
            caption.show();
        }
    });
});

我现在是这样做的:

$(document).ready(function()
{
    $('.photoGallerySlideshowAlbum').each(function(index, value)
    {
        var elPager = $(this).parent().find('.photoGallerySlideshowPager');

        $($(this)).cycle(
        {
            fx: 'fade',
            pager: elPager,
            activePagerClass: 'selected',
            pagerAnchorBuilder: function(idx, slide)
            { 
                return 'li:eq(' + idx + ') a';
            },
            after: function(currentImage, nextImage, options)
            {
                var captions = $(this).parent().parent().find('.photoGallerySlideshowCaptions').children().hide();
                var caption = $(captions[options.currSlide]);
                caption.show();
            }
        });
    }); 
});

但我不知道如何更改 pagerAnchorBuilder。 我的 html 看起来像这样(不能更改)。

<div class="photoGallerySlideshowPager">
                    <ul>
<li><a href="#">a</a></li>
<li><a href="#">b</a></li>
<li><a href="#">c</a></li>
                    </ul>
                </div>

【问题讨论】:

  • 我不确定我是否明白你的问题。你想要多个幻灯片,对吧?你不能在这里再创建一个吗?我错过了什么吗?你的意思是你不想为寻呼机使用 ID?
  • jQuery 循环的 pager 属性为演示中的一个元素获取一个 id,他想传递与当前正在初始化的滑块相关的东西。

标签: jquery plugins cycle


【解决方案1】:

在 jQuery 循环引用中指出:

pager:         null,  // element, jQuery object, or jQuery selector string for the element to use as pager container

http://jquery.malsup.com/cycle/options.html

所以你应该能够像这样将一个 jQuery 对象传递给这个属性:

pager: $(this).closest('.nav')

【讨论】:

    猜你喜欢
    • 2010-11-25
    • 2014-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多