基本上,我正在使用Tooltip的title属性,我想将Colorbox中的图像描述从title更改为alt。我找到了一些解决方案,但它们与Wordpress插件有关,而我正试图在网站上进行。
脚本:
$(document).ready(function(){
//Examples of how to assign the Colorbox event to elements
$(".group1").colorbox({rel:"group1", transition:"elastic", maxHeight:"90%", scalePhotos:true});
});
$(function() {
$(".thumb").tooltip({
position: {
my: "center bottom-20",
at: "center top",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});
});
HTML:
<div class="mosaic-block bar">
<a class="group1" href="images/AMAASb.jpg" title="As Much Art As Science.">
<img src="images/AMAASs.png" title="Title: As Much Art As Science. TEXTTEXET" border="0"
style="width: 100%;" class="thumb"/>
</a>
</div>
谢谢!
答案 0 :(得分:3)
几乎直接从颜色盒使用指南中拉出:
// Colorbox can accept a function in place of a static value:
$("a.gallery").colorbox({title: function(){
return $(this).attr('alt');
}});
哦,看起来你需要从链接中的图像中拉出alt。因此,您需要查询锚标记的子项。也许是这样的:
$(this).children('img').attr('alt');