【发布时间】:2013-06-27 01:06:44
【问题描述】:
我试图在 jQuery 灯箱中获取对图库图像的 alt 标记的引用,并在它跳转到更大图像的链接并将其放入灯箱后,将其显示为图像下方的标题。
$(function(){
$('.gallery a').on('click', function(e){
var image_source = $(this).attr('href');
var text = $('.gallery a img').attr('alt');
$('#content').html('<img src="' + image_source + text + '">');
/* .html('<p style="color:#fff;">' + alt_text + '</p>');
-----------above was the other method I tried which didn't work so I commented it out-- -----*/
$('#lightbox').show();
e.preventDefault();
});//End Gallery
$('#lightbox').on('click', function(){
$(this).hide();
$('#content img').remove();
});
});//End Ready
当然,我希望在单击图库缩略图时显示相应图像的 alt 标签以显示相应的较大图像。
任何建议将不胜感激,在此先感谢! 这是它的 JSFiddle: http://jsfiddle.net/graphicsinc/37A4y/13/
【问题讨论】: