STEEL
STEEL

Reputation: 10057

Open Next inline Colorbox Div on click

I have 2 images, when I click on them it open the respective #DIV. And it works fine. Im using colorbox jQuery plugin.

But I have even added 2 links ajNext and ajPrev.

I want to open next or previous inline DIV with them. Is it possible to open them as a grouped DIV, kinda like a gallery next prev functionality. Kindly help me :)

$(document).ready(function(){
        $(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
        $(".inline").colorbox({inline:true, width:"1020px", height: "560px"});

        $('#ajNext').live('click', function(){
            $.fn.colorbox.next();
        });
    });

and my HTML:

<li><a class="inline" href="#profile1"><img src="car1.jpg"></a></li>
<li><a class="inline" href="#profile2"><img src="car2.jpg"></a></li>

<div id="inline_profiles"'>
            <div id="profile1" class="profilex">
                <img src="images/kala-mela/car1_1.jpg">
                <p><strong>Prasanna R. Gogilwar. 111</strong></p>
                <p>111 Prasanna loves birds and his favourite is the Hornbill. He mentioned that the side lights of the Nano bear a striking resemblance to the bird and the thought of owning a Nano with his design on it would be extremely exciting. He would drive is everywhere so that people get a chance to admire his work.</p>
                <a id="ajPrev"></a>
                <a id="ajNext"></a>
            </div>

            <div id="profile2" class="profilex">
                <img src="images/kala-mela/car1_1.jpg">

                <p><strong>Prasanna R. Gogilwar. 2222</strong></p>
                <p>222 Prasanna loves birds and his favourite is the Hornbill. He mentioned that the side lights of the Nano bear a striking resemblance to the bird and the thought of owning a Nano with his design on it would be extremely exciting. He would drive is everywhere so that people get a chance to admire his work.</p>
                <a id="ajPrev"></a>
                <a id="ajNext"></a>
            </div>
        </div>

Upvotes: 0

Views: 1049

Answers (1)

webdeveloper
webdeveloper

Reputation: 17288

<img src="car2.jpg">

You need to close img elements <img />

<a id="ajPrev"></a>
<a id="ajNext"></a>

id must be unique

$(".inline").colorbox({inline:true, width: '50%', rel: 'profilex'});

$('.ajPrev').on('click', function(){
    $.fn.colorbox.prev();
});
$('.ajNext').on('click', function(){
    $.fn.colorbox.next();
});

Demo: http://jsfiddle.net/wPdBy/

Upvotes: 1

Related Questions