我使用非常棒的jQuery-plugin Galleriffic来显示图片库。这很好用,但我想要实现的是获得当前显示的图像的标题。如果我将鼠标光标放在图像上,它会显示标题。不幸的是,我还没有设法通过jQuery获得这个标题。
任何帮助都是非常感谢的。
谢谢,
enne
编辑:这是该插件的链接:http://www.twospy.com/galleriffic/
这里还有一些代码。我不确定,但我认为图像在以下容器中显示为背景图像:
<div id="slideshow" class="slideshow">
</div>
我使用以下javascript代码:
$('div.slideshow').hover(
function () {
//Get the title here
},
function () {
}
);
好吧,firebug给我看了这段代码:
<div id="loading" class="loader" style="display: none;"></div>
<div id="slideshow" class="slideshow">
<div id="slide-container">
<span class="image-wrapper current" style="opacity: 1;">
<a class="advance-link" title="Chrysanthemum" href="#2" rel="history">
<img alt="Chrysanthemum" src="http://ulc.local/sites/default/files/imagecache/preset_image_gallery_diashow/sites/default/files/Chrysanthemum_3.jpg">
</a>
</span>
</div>
所以这里我需要图像的"alt“属性。
发布于 2012-04-03 17:03:11
您可以使用此选择器选择当前img
$('div.slideshow .current img')
发布于 2012-04-03 16:24:34
如果您将鼠标悬停在图像上,它会显示标题-文本。你可以用下面的代码抓取title-text:
$('img').hover(function{
$(this).attr('title');
});
如果您提供您现在拥有的代码,我可以尝试将我的解决方案应用于您的代码。
发布于 2012-08-17 14:50:57
对于那些来这里寻找获得所选图像的方法的人,而不是显示的图像(下面的解释),请使用以下代码:
$("div.navigation .thumbs .selected img")
不同的是上面的答案给了你更大的标签,用于查看最终渲染的图像。在我的例子中,我想要的是所选缩略图的,因为我需要获取它的id和name属性。渲染不会从选定的缩略图中获取name或id属性,只会获取src和alt属性。
为了把我推向正确的方向,我将投票给最初的答案。
https://stackoverflow.com/questions/9997312
复制相似问题