开发者

Jquery/Colourbox many links to colourbox galleries/Array?

Thanks Christopher for jQuery / Colorbox - create a separate link 开发者_JS百科to open the colorbox? I need more than one link, how can I coding it more elegant way than now i will have nine galleries..An Array? http://carlossilva.org/test_colorbox.html

Thank everybody for taking time!


There are many ways to do that. Here is a simple one that dynamically forms the REL attribute. You could get much more elegant than this with a few more minutes...

HTML

<body>
<ul>
    <li id="gal0">Gallery 1</a>
    <li id="gal1">Gallery 2</a>
</ul>

<div class="cannotview">
    <a href="img/tour1.jpg" rel="gal0"></a>
    <a href="img/tour2.jpg" rel="gal0"></a>
    <a href="img/tour3.jpg" rel="gal1"></a>
    <a href="img/tour4.jpg" rel="gal1"></a>
</div>

</body>

JQuery

$().ready(function () { 
   $('li').one('click', function () { 
        var myRel ='a[rel=' + $(this).attr("id") + ']';
        var $gallery = $(myRel).colorbox().eq(0);
        $gallery.click(); 

        $(this).click(function(){
            $gallery.click();
        });
    });
});

Regards, Kevin M.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜