我在啓動fancybox時遇到問題。我想在#content塊內的所有圖片上使用fancybox。所有的圖像有以下代碼:在所有帶有圖像的定位標記上啓動fancybox
<a href="img.jpg">
<img title="title" src="img.jpg" alt="alt" width="225" height="169">
</a>
我不想使用特殊類的鏈接(圖片由用戶通過TinyMCE的管理)。我想:
$("#content a").has('img').fancybox({
..fancybox settings
});
和以及
$("#content a img").parent('a').fancybox({
..fancybox settings
});
沒有任何的運氣。 $("#content a").has('img').hide()
完美地工作 - 所以選擇適當的元素就好了。
編輯:也許對於更好地理解:使用$("#content a")
作品,但適用於所有<a>
標籤,這意味着像<a href="google.com">google</a>
以及簡單的聯繫是「fancyboxed」。
EDIT2: HTML代碼:
<div id="content">
<p>Lots of text.
<a href="href">
<img src="src" alt="alt" width="225" height="169" />
</a>
</p>
<p>another text</p>
<p>more text <a href="http://www.google.com">Simple link which should not be opened by fancybox</a></p>
</div>
THX的任何想法。使用此給出一個相對
u能解釋更多的笏ü想要什麼? – Ghostman 2012-03-18 17:16:37
我想打開fancybox中的所有圖像。所以我必須在所有標籤上打開fancybox,標籤裏面有圖像。 – tsusanka 2012-03-18 17:19:38