我試圖使用名爲ColorBox的Jquery Lightbox(http://colorpowered.com/colorbox/),但我遇到了一些麻煩。Jquery ColorBox:顯示內嵌內容,如圖庫
我想使用燈箱顯示內嵌內容,但也有下一個和上一個按鈕出現。這樣,就像在照片庫中一樣,我將能夠瀏覽與下一個和上一個按鈕共享相同ID屬性的所有項目。如果我將它硬編碼到模板中,它會起作用,但是如果我將它自動粘貼到帖子末尾,它就不會。
我經常添加一個新元素,所以向開始添加一個新元素需要比我想要的更長的時間。所以我自動執行這個程序,生成的代碼看起來和你的完全一樣(在你的文章中),但是colorbox不起作用。現在是否有人如何解決它(如果可能)?幫助將不勝感激。
這工作:
<p><a class="group1" href="#box1">Grouped Photo 1</a></p>
<p><a class="group1" href="#box2">Grouped Photo 2</a></p>
<p><a class="group1" href="#box3">Grouped Photo 3</a></p>
<div id="box1">
Some text in box 1 Some text in box 1
Some text in box 1
Some text in box 1
Some text in box 1
Some text in box 1
</div>
<div id="box2">
Some text in box 2
Some text in box 2
Some text in box 2
Some text in box 2
Some text in box 2
</div>
<div id="box3">
Some text in box 3
Some text in box 3
Some text in box 3
Some text in box 3
Some text in box 3
</div>
如果我編輯這樣上面的代碼它不
<div class="links">
<p><a class="group1">Grouped Photo 1</a></p>
<p><a class="group1">Grouped Photo 2</a></p>
<p><a class="group1">Grouped Photo 3</a></p>
</div>
<div class="boxes">
<div>
Some text in box 1 Some text in box 1
Some text in box 1
Some text in box 1
Some text in box 1
Some text in box 1
</div>
<div>
Some text in box 2
Some text in box 2
Some text in box 2
Some text in box 2
Some text in box 2
</div>
<div>
Some text in box 3
Some text in box 3
Some text in box 3
Some text in box 3
Some text in box 3
</div>
</div>
和Javascript:
$('.links a').each(function(index) {
$(this).attr("href","#box"+index);
});
$('.boxes div').each(function(index) {
$(this).attr("id","#box"+index);
});
$(".group1").colorbox({rel:'group1', inline:true, href:$(this).attr('href'), width:"60%"});
此經過的所有環節和爲它們添加與鏈接在href屬性中相同的id
只是一個小忠告:我不會用顏色框,如果我是你。這在一段時間以來一直是屁股或我的痛苦。我搬到了影子箱。 Fancybox也不錯。 –
好的,會嘗試shadowbox thx :) – user1412371