我想知道如何创建一个灯箱,用网址加载页面中的图像 链接的数量
这是我的代码,但它不起作用:
$("a.picture").click(function() {
$.fancybox({
'padding' : 0,
'overlayShow' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'titlePosition' : 'over',
'type' : 'image',
'titleFormat' : function(title, currentArray,
currentIndex, currentOpts) {
return '<span id="fancybox-title-over">' + (currentIndex +
1) + ' / ' + currentArray.length + (title.length ? ' ' +
title : '') + '</span>';
}
});
return false;
});
和 HTML 代码
<a class="picture" href="http://localhost/test/my_page.html" title="Picture Page">Link</a>
谢谢!
最佳答案
上面的脚本还假设您有一个如下所示的 html:
<a class="picture" href="images/picture.jpg">open image</a>
那么您还应该在脚本中添加选项href
,例如
$("a.picture").click(function() {
$.fancybox({
'padding' : 0,
'overlayShow' : false,
'href': this.href, //<--LIKE THIS
// etc....
该选项将提供 fancybox 加载图像的 URL。
注意:提出问题是可以的,我们很乐意提供帮助,但正如 @ofir 评论的那样,您应该提供反馈并接受其他人提供的正确答案,这样人们就会有动力帮助您解决问题 future 。
关于javascript - Fancybox - 如何从 url 加载图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9649406/