我正试图从其他彩盒图像之外的链接打开一个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>
解决方法
这是一个类似于我的项目的东西.
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}); }); });