jQuery/Colorbox-创建一个单独的链接来打开colorbox? [英] jQuery / Colorbox - create a separate link to open the colorbox?

查看:56
本文介绍了jQuery/Colorbox-创建一个单独的链接来打开colorbox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从其余颜色框图像外部的链接打开jQuery颜色框.因此,所有示例如下所示:

I'm trying to open a jQuery Colorbox from a link outside the rest of the colorbox images. So, all of the examples look like this:

<a href="image1.png" rel="group1"><img src="thumb1.png" /></a>
<a href="image2.png" rel="group1"><img src="thumb2.png" /></a>
<script>$("a[rel='group1']").colorbox();</script>

好的,很好,但是我还需要从单独的链接中打开该颜色框:

OK, that's fine, but I also need to open that colorbox from a separate link:

<a href="?"> this link should also open the colorbox </a>

我该放在哪里做些什么?所有的colorbox示例仅显示第一个代码块中的内容,而我不是jQuery专家.

What do I have to put where to do that? All of the colorbox examples just show what's in the first code block, and I'm no jQuery expert.

推荐答案

这里有一个类似的东西适用于我的项目.

Here's a similar thing that worked for my project.

HTML

//I "display:none" the images gallery to hide them...
<div style="display:none;">
 <a href="image1.jpg" rel="example1">Grouped Photo 1</a>
 <a href="image2.jpg" rel="example2">Grouped Photo 2</a>
 <a href="image3.jpg" rel="example3">Grouped Photo 3</a>
</div>

//...then when I click on this JPG image the group of images (above) appear in a colorbox
<img src="circle1.jpg" width="147" height="149" alt="circle" class="circle1" />

这是JQUERY

$(document).ready(function(){

     //when i "click" on the image with a class of "circle1" it opens the "example1" group
     $('.circle1').click(function() {
        $("a[rel='example1']").colorbox({open:true});
     });

});

这篇关于jQuery/Colorbox-创建一个单独的链接来打开colorbox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆