【发布时间】:2011-07-29 19:43:12
【问题描述】:
如果用户单击该 div 内的链接,我想要做的是阻止单击该 div。 但不使用 .click(function() {});在链接上。
代码如下:
$('div.feature').click(function() { window.location = $(this).attr('rel');});
这里是 div 的示例内容:
<div id="feature" rel="urlnumberone">
some text
<a href="javascript:topicchange(this);" class="insideLink">Link</a>
</div>
由于某些特定原因我不能使用这样的东西
$('.insideLink').click(function(event){
event.stopImmediatePropagation();
});
我必须使用这个“topicchange()”函数,有什么办法可以防止事件传播?
谢谢!
【问题讨论】:
-
为什么你不能使用
$('.insideLink').click(topicchange)和function topicchange(e){ e.stopImmediatePropagation(); //your code follows }
标签: jquery events html clickable propagation