且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在fancybox中获取当前图像索引?

更新时间:2023-11-17 08:41:16

类似以下内容应该可以:

Something like the following should do just fine:

var src = $('#fancybox-img').attr('src'); // Looks for the *fancyboxed* image
var idx = $('a[href="'+src+'"]').index(); // Gets the index of the thumbnail

如果您使用某些自定义DOM层次结构,则您可能必须采用此解决方案.

You may have to adapt this solution if you use some custom DOM hierarchy.