为fancybox图片/视频添加标题
Adding caption to fancybox images/video
我目前有fancybox
显示所有正确的图像/视频。然而,我似乎无法让它显示与每次调用fancybox
相关联的标题。
我正在使用Fancybox V2.1.5
$(document).ready(function(){
$(".fancyYoutube").live('click',function(){
$.fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'titleShow' : 'true',
'speedIn' : '100',
'width' : 680,
'height' : 395,
'href' : this.href.replace(new RegExp("watch''?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : true,
},
beforeLoad: function() {
this.title = $(this.element).attr('caption');
}
});
return false;
});
});
我在需要的部分中使用caption=
,但它仍然没有显示标题文本:(
我也在使用最新的JQuery插件。
任何帮助都将是伟大的,谢谢!
编辑:问题已解决:
$(document).ready(function(){
$(".fancyYoutube").live('click',function(){
$.fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'title' : this.title,
'speedIn' : '100',
'width' : 680,
'height' : 395,
'href' : this.href.replace(new RegExp("watch''?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : true
}
});
return false;
});
});
仅需要title : this.title,
如果我记得很清楚(我也在这里检查过:http://fancybox.net/blog)你需要这些参数
'titlePosition' : 'inside',
'titleFormat' : formatTitle
其中formatTitle是一个附加标题的函数
function formatTitle(title, currentArray, currentIndex, currentOpts) {
return '<div id="tip7-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="/data/closelabel.gif" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
}
我认为这里有问题
this.title = $(this.element).attr('caption');
尝试使用类似的id(在不适合的地方使用适当的id)
$(this).html( $(this).attr('caption') );
相关文章:
- 为li元素添加标题
- 根据值向表的每个 td 添加标题属性
- 为网站的所有页面添加标题
- 如何为简单的 HTML 画廊添加标题
- 如何为这些图像添加标题标签
- AmChart - 未定义添加标题
- 为非常基本的jquery轮播添加标题
- 在地图框 API 中向多点标记图层添加标题和描述
- 用于添加标题的脚本及其对 HTML 文档中所有锚标记的值
- Jquery同位素PLugin:自定义布局模式:类别行-如何为每个类别行添加标题
- 向Jquery全屏幻灯片添加标题
- 如何跳过第一行并添加标题以下载csv文件
- 为fancybox图片/视频添加标题
- 向AJAX调用添加标题的目的是什么?
- 为jquery caroufredsel插件项添加标题
- 添加标题使页面不显示图像
- 如何使用jquery在图像上添加标题
- 添加标题时,悬停在表情符号在javascript
- 使用JQuery为动态加载的表添加标题
- 如何在javascript中为按钮添加标题