Javascript Fancybox中的Target href
我正在尝试在标题中放置一个链接,它基本上是选定的锚href,带有前缀。我怎样才能做到以下几点?我希望能够在选定的锚元素上获取this.hrefJavascript Fancybox中的Target href,javascript,jquery,fancybox,fancybox-2,Javascript,Jquery,Fancybox,Fancybox 2,我正在尝试在标题中放置一个链接,它基本上是选定的锚href,带有前缀。我怎样才能做到以下几点?我希望能够在选定的锚元素上获取this.href $(".gallery-module > li > a").fancybox( { title : '<a href="'+ this.href + '-large">DOWNLOAD</a><br> High Resolution File, 300dpi' }); $(“.gall
$(".gallery-module > li > a").fancybox(
{
title : '<a href="'+ this.href + '-large">DOWNLOAD</a><br> High Resolution File, 300dpi'
});
$(“.gallery module>li>a”).fancybox(
{
标题:“
高分辨率文件,300dpi”
});
绑定fancybox时:
$(".gallery-module > li > a").fancybox({
title: '<a href="'+ this.href + '-large">DOWNLOAD</a><br> High Resolution File, 300dpi'
});
在
$('.gallery module>li>a')中。每个
回调,这个
将是您要查找的
。我假设您使用的是fancybox v1.3.x,不是吗
对于该版本,您不能直接引用this.href
,除非它位于回调函数中。在您的情况下,您可以使用titleFormat
选项自定义标题,如
$(".gallery-module > li > a").fancybox({
titleFormat: function(){
return '<div class="newTititleWrap"><a href="'+ this.href + '-large">DOWNLOAD</a><br> High Resolution File, 300dpi</div>'
}
});
我将发布v1.3.4版的解决方案,以防它对其他人有所帮助。问题出在哪里,出在哪里?您有我们可以看到并使用的解决方案吗?那么,您的问题解决了吗?对提供的答案有任何反馈吗?你是对的,我错过了标签“fancybox-2”(我的错)。。。将编辑答案。
$(".gallery-module > li > a").fancybox({
titleFormat: function(){
return '<div class="newTititleWrap"><a href="'+ this.href + '-large">DOWNLOAD</a><br> High Resolution File, 300dpi</div>'
}
});
$(".gallery-module > li > a").fancybox({
beforeShow : function() {
this.title = '<div class="newTititleWrap"><a href="'+ this.href + '-large">DOWNLOAD</a><br> High Resolution File, 300dpi</dv>';
}
}); // fancybox