我得到了这个:
$(document).ready(function(){
$(".top_up").colorbox(
{
rel:'group3',
opacity: '0.2'
}
);
});
然后是这样的:
<a id="172703536171203_661714" class="top_up" rel="pics" href="FULL_IMAGE_LINK" title=""><img src='THUMBNAIL' style='border: medium solid #1A1A1A;' /></a>
工作得很好..
但我希望 href=""不是完整图像链接,并让 colorbox 在 rel 属性或其他属性中查找完整图像链接(没关系,只是不同于 href 和 id 属性) .
我该怎么做?
最佳答案
你已经完成了 99% 的任务。但是,您还可以使用自定义数据属性,而不是使用 rel
属性,从而使代码更具可读性:
<a data-colorbox-href="http://...">
<img ... />
</a>
然后使用 colorbox 实例化中的“href”选项,使用回调从单击的链接中获取 data-colorbox-href
(或其他内容)的值:
$(".top_up").colorbox({
//all the other options you have up there, plus...
href: function() {
return $(this).attr("data-colorbox-href");
}
});
关于jquery - 从 href 属性以外的其他内容加载 colorbox 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12371646/