jQuery / Colorbox – 创建一个单独的链接来打开彩盒?

前端之家收集整理的这篇文章主要介绍了jQuery / Colorbox – 创建一个单独的链接来打开彩盒?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正试图从其他彩盒图像之外的链接打开一个jQuery ColorBox.所以,所有的例子都是这样的:
<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>

好的,没关系,但我还需要从单独的链接打开那个颜色框:

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

我该怎么做才能做到这一点?所有的colorBox示例都只显示了第一个代码块中的内容,而且我不是jQuery专家.

解决方法

这是一个类似于我的项目的东西.

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相关文章