我有一個手風琴設置爲這樣:jQuery的手風琴防止鼓泡/允許默認鏈接操作
$('.shortheadline').accordion({ active: false, header: '.headline', autoHeight: false, animated: 'slowslide', changestart: function(event, ui) { $('.brief').css('min-height','0') }, change: function(event, ui) { $('.brief:visible').css('min-height','80px'); $('.headline').blur(); } });
我想要的點擊只登記在.headline DIV,不裏面的鏈接。鏈接應該帶你到文章頁面。
<div class="shortheadline">
<div class="entry">
<div class="headline">
<div class="timestamp">11:34 AM</div>
<div class="title"><a href="http://beta.macobserver.com/tmo/article/jeff_gamet_shares_iphone_tips_and_tricks_on_macjury/">Jeff Gamet Shares iPhone Tips and Tricks on MacJury</a></div>
</div>
<div class="brief">
<div class="teaser_image"> <img src="/imgs/cache/imgs/teaser_images/20090708macjury_new-0x80.png" width="80" height="80" id="teas_48236" alt="macJuryJeff Gamet Shares iPhone Tips and Tricks on MacJury" /></div>
<div class="teaser"><p><em>The Mac Observer's</em> Jeff Gamet joined <em>MacJury</em> host Chuck Joiner to talk about Apple's iPhone OS 3.0, the iPhone 3GS, and to share some iPhone tips and tricks, too.</p> </div>
</div>
</div>
<!-- more entries -->
</div>
有沒有辦法來防止事件冒泡,所以手風琴只觸發點擊div? 或者有沒有辦法讓鏈接的默認動作繼續?
我已經試過:
$("a").click(function(){ window.location=this.href; });
這確實讓鏈接功能,但它不會讓用戶在新標籤/窗口中打開鏈接。
謝謝!
非常感謝!我擡頭看了停止傳播,這正是我正在尋找的。我甚至不需要window.location部分。 – user139195 2009-07-16 05:29:23