jQuery / Colorbox - create a separate link to open the colorbox?

后端 未结 4 460
一个人的身影
一个人的身影 2021-01-12 11:44

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:



        
相关标签:
4条回答
  • 2021-01-12 12:15

    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" />
    

    Here's the 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});
         });
    
    });
    
    0 讨论(0)
  • 2021-01-12 12:24

    Try this:

    $(".link-to-click").click(function() {
       $("a.colorbox-link").colorbox({open:true, rel:'colorbox-class-group'});
    });
    
    0 讨论(0)
  • 2021-01-12 12:27

    This example works, but without next and previous selections: http://jsfiddle.net/pd6JN/8/

    0 讨论(0)
  • 2021-01-12 12:31

    Ah, figured it out! This works:

    Change the first link to:

    <a href="image1.png" rel="group1" id="something"><img src="thumb1.png" /></a>
    

    Then, set up our extra link like this:

    <a href="#" onclick="$('#something').colorbox({rel:\'post' . $post->ID . '\', open:true});">click here</a>
    
    0 讨论(0)
提交回复
热议问题