小编Phi*_*hil的帖子

jquery:在可点击的div中保持<a>链接可点击

我想要做的是阻止点击div,如果用户点击该div内的链接.但是没有使用.click(function(){}); 在链接上.

这是代码:

$('div.feature').click(function() { window.location = $(this).attr('rel');});
Run Code Online (Sandbox Code Playgroud)

这是div的示例内容:

<div id="feature" rel="urlnumberone">
some text
<a href="javascript:topicchange(this);" class="insideLink">Link</a>
</div>
Run Code Online (Sandbox Code Playgroud)

由于某些特定原因,我不能使用这样的东西

$('.insideLink').click(function(event){
    event.stopImmediatePropagation();
});
Run Code Online (Sandbox Code Playgroud)

我必须使用这个"topicchange()"函数,有什么方法可以阻止事件传播?

谢谢!

html jquery events propagation clickable

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

clickable ×1

events ×1

html ×1

jquery ×1

propagation ×1