0

我有 2 张图片,当我点击它们时,它会打开相应的#DIV。它工作正常。我正在使用彩盒 jQuery 插件。

但我什至添加了 2 个链接 ajNext 和 ajPrev。

我想用他们打开下一个或上一个内联 DIV。是否可以将它们作为分组 DIV 打开,有点像画廊下一个上一个功能。请帮助我:)

$(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();
        });
    });

和我的 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>
4

1 回答 1

1
<img src="car2.jpg">

您需要关闭img元素<img />

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

id必须是唯一的

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

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

演示:http: //jsfiddle.net/wPdBy/

于 2013-04-02T08:18:37.473 回答