gpt4 book ai didi

jquery Accordion 防止冒泡/允许默认链接操作

转载 作者:行者123 更新时间:2023-12-01 00:40:14 24 4
gpt4 key购买 nike

我有一个 Accordion 设置:

 $('.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>

有没有办法防止事件冒泡,以便 Accordion 仅在单击 div 时触发?或者有没有办法让链接的默认操作继续?

我已经尝试过:

$("a").click(function(){ window.location=this.href;  });

这确实使链接起作用,但它不允许用户在新选项卡/窗口中打开链接。

谢谢!

最佳答案

尝试

$("a").click(function(event){ event.stopPropagation(); });

点击函数传递一个“事件”对象。通过调用事件对象的“stopPropagation”方法,可以防止冒泡。

关于jquery Accordion 防止冒泡/允许默认链接操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1135466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com