【问题标题】:Thumbnail Captions Single and Double Click?缩略图标题单击和双击?
【发布时间】:2010-07-30 22:03:32
【问题描述】:

我对这一切几乎一无所知,所以我向你寻求一些急需的帮助。如果您需要查看更多代码或信息,请询问,我会尽快回复。

以下代码 sn-p 是我用于照片库的代码:

http://luisposada.co.uk/home/photography-2/

问题是当您从左到右浏览缩略图时单击主图片下方的标题,但双击时仅从右到左显示。显然,无论单击缩略图的顺序如何,单击一下,我都希望更改字幕。

非常感谢。

<script type="text/javascript"> 

$(function() {
   $('#feature').cycle({
       speed:       1000,
       timeout:     <?php echo $speed; ?>
   });

$("#yc_thumbnail_frame a").live("click",function(){
    $(".yc_img_fullsize").each(function(index) {
        if ($(this).is(":visible")) {
            var text = $(this).attr("alt");
            $(".caption").html(text);
        }
    });
  });
});

$(window).load(function() {
   $("img.yc_img_fullsize").each(function(index) {
    if ($(this).is(":visible")) {
        var text = $(this).attr("alt");
        $(this).parent().after("<p class='caption'>" + text + "</p>");
    }
  });

});

</script> 

【问题讨论】:

  • 其实这一切都在上面。有什么帮助吗?

标签: jquery wordpress gallery caption


【解决方案1】:

#yc_thumbnail_frame a click 事件处理程序的以下更改应该会为您修复它:

$("#yc_thumbnail_frame a").live("click",function(){

    // Instead of looking for the visible image, find the one that matches the thumbnail src
    var thumbSrc = $(this).find('img').attr('src');
    $(".yc_img_fullsize").each(function(index) {
        if ($(this).attr('src') == thumbSrc) {
            var text = $(this).attr("alt");
            $(".caption").html(text);
        }
    });
  });
});

它当前无法按预期工作的原因是,当您单击其中一个缩略图链接时,它会循环浏览所有大图像并确定哪一个可见。当它找到可见的文本时,它会从它的替代文本中设置标题文本。

似乎将大图像设置为可见比尝试确定其标题文本要慢一些。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 1970-01-01
    • 2012-02-11
    • 1970-01-01
    • 1970-01-01
    • 2019-06-28
    相关资源
    最近更新 更多