1
我想利用標題作爲元素腳本以及縮略圖助手。如果我爲兩者使用相同的類名稱,例如..(.fancybox-thumb),則只有title作爲元素起作用。fancybox標題作爲元素和縮略圖幫手
在此先感謝您的幫助。
標題元素
$(".fancybox-thumb")
.attr('rel', 'gallery')
.fancybox({
beforeLoad: function() {
var el, id = $(this.element).data('title-id');
if (id) {
el = $('#' + id);
if (el.length) {
this.title = el.html();
}
}
}
});
縮略圖幫手
$(".fancybox-thumb")
.attr('rel', 'gallery')
.fancybox({
prevEffect : 'none',
nextEffect : 'none',
helpers : {
title : {
type: 'outside'
},
thumbs : {
width : 60,
height : 60
}
}
});
如果我使用相同的類名,即雙方..(.fancybox拇指),只有標題爲元素的作品。
<div id="main" class="wrapper clearfix">
<a class="fancybox-thumb" rel="fancybox-thumb" href="http://farm7.staticflickr.com/6111/6285920681_67917e8062_b.jpg" title="walk in the park (ewitsoe)">
<img src="http://farm7.staticflickr.com/6111/6285920681_67917e8062_m.jpg" alt="" />
</a>
<a class="fancybox-thumb" rel="fancybox-thumb" href="http://farm7.staticflickr.com/6106/6347065961_bb73745e70_b.jpg" data-title-id="title-1">
<img src="http://farm7.staticflickr.com/6106/6347065961_bb73745e70_m.jpg" alt="" />
</a>
<div id="title-1" class="hidden">
This is 1st title. <a href="http://google.com" target="blank">Some link</a>
</div><!--title-1-->
</div> <!-- #main -->
感謝@JFK,這個偉大工程,爲一個畫廊。我正在使用多個畫廊,所以現在發生的事情是它將所有縮略圖串在一起,就像一個畫廊一樣。我想我可以給每個畫廊它自己的類(.fancybox拇指1)等,這似乎很笨重,但。 你看到一種方法來改變腳本;在這一點上,我假設.attr('rel','gallery')識別多個畫廊? – user1857250
@ user1857250:看到我編輯的答案 – JFK
謝謝@JFK,很棒。我感謝你的時間。 – user1857250