【问题标题】:Add title to jQuery Cycle slideshow from Alt attribute?从 Alt 属性向 jQuery Cycle 幻灯片添加标题?
【发布时间】:2011-06-25 01:18:47
【问题描述】:

我正在制作幻灯片,需要为每张循环播放的图片显示一个标题。我为它们创建了 alt 属性,并试图为每个图像循环显示它们,但它只显示第一个。我不确定如何将我拥有的代码放入画廊的循环“循环”中?这有意义吗?这就是我所拥有的,(嗯,我的意思是其中的一部分):) 谢谢!

$('#slideshow').before('<div class="navigation">').cycle({
fx:     'fade',
timeout: 6000,
pager:  '.navigation'
});

$('.image_title').html($(this).find('img').attr('alt'));

【问题讨论】:

    标签: jquery jquery-plugins jquery-cycle


    【解决方案1】:

    只需将该代码移动到回调之前或之后。例如:

    $('#slideshow').before('<div class="navigation">').cycle({
        fx:     'fade',
        timeout: 6000,
        pager:  '.navigation',
        after:   function() {
            var title = $(this).attr('alt');
            $('.image_title').html(title);
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2014-05-17
      • 1970-01-01
      • 1970-01-01
      • 2012-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-21
      相关资源
      最近更新 更多