0

基本上,我使用的是工具提示的标题属性,我想将 Colorbox 中图像的描述从标题更改为 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>

谢谢!

4

1 回答 1

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');
于 2013-08-08T18:08:35.427 回答