jQuery prettyPhoto-从不是图像的链接打开画廊 [英] JQuery prettyPhoto - open gallery from a link that's not an image
问题描述
我正在使用JQuery prettyPhoto灯箱克隆,效果很好,但是有一个小问题.
I'm using the JQuery prettyPhoto lightbox clone, and it works great, but I have one small issue.
所有图像都具有以下格式:
All images have the following format:
<a href='imageURL' rel='prettyPhoto[gallery1]'><img src='imageURL' style='height:100px;' title='photoname' /></a>
我显示了4张图像,而使用<div>
和style='display:none;'
隐藏了另外10张图像.单击4张图像中的任何一张,将打开图库,显示所有14张照片.很好.
I have 4 images showing and another 10 hidden using a <div>
with style='display:none;'
. Clicking any of the 4 images opens the gallery, showing all 14 photos. That's fine.
但是我还需要有一个链接,上面写着查看全部14张照片",单击该链接即可打开图库.现在,如果我不给文本链接提供<a href='imageURL'>
,它将不起作用.但是,如果我将其链接到例如第一个图像,则该图像将在画廊中显示两次.我该如何避免呢?
But I also need to have a link saying 'view all 14 photos' that, when clicked, opens the gallery. Now, if I don't give <a href='imageURL'>
to the text link, it doesn't work. But if I link it to, for example, the first image, then that image is shown twice in the gallery. How can I avoid that?
我考虑过将文本链接链接到其中一个隐藏图像,但这不是解决方案,因为这4个可见图像是使用PHP随机选择的.
I thought about linking the text link to one of the hidden images instead, but that's not a solution, since the 4 visible images are randomly chosen using PHP.
推荐答案
将链接更改为:
<a id="startPrettyPhoto">View all photos</a>
并将其添加到文档中,您可以在其中设置prettyPhoto
And add this to the document ready where you set up prettyPhoto
$("#startPrettyPhoto").click(function() {
$("a[rel^='prettyPhoto']:first").click()
});
这篇关于jQuery prettyPhoto-从不是图像的链接打开画廊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!