jQuery Fancybox Not Recognizing Element

2019-03-05 00:37发布

问题:

<a id="attachment3655" rel="Lightbox_109160" href="https://xenogamers.org/attachment.php?attachmentid=3655&d=1350682390">
<img class="thumbnail" border="0" style="float:CONFIG" alt="Click image for larger version.  Name: 253635_10150631007825720_595485719_18819556_7955719_n.jpg  Views: 32  Size: 100.9 KB  ID: 3655" src="https://xenogamers.org/attachment.php?attachmentid=3655&d=1359000187&thumb=1" title="Click image for larger version.  Name: 253635_10150631007825720_595485719_18819556_7955719_n.jpg  Views: 32  Size: 100.9 KB  ID: 3655">
</a>

$(document).ready(function () {
    $("#attachment3655").fancybox({
        openEffect: 'none',
        closeEffect: 'none'
    });
});

It won't recognize the a id at all, and I can't figure out why. I can't change the source above easily so I cannot figure out a way to do this with only jquery.

I've been working on it here: http://jsfiddle.net/2k8EP/226/

回答1:

Just add type: "image" to your API options

$(document).ready(function () {
    $("#attachment3655").fancybox({
        openEffect: 'none',
        closeEffect: 'none',
        type: "image"
    });
});

Your forked jsfiddle

BTW, that is documented HERE, tab FAQ, number 5.