如何防止并发javascript执行?
我有这样的html代码块如何防止并发javascript执行?,javascript,jquery,html,Javascript,Jquery,Html,我有这样的html代码块 <div id="some-div"> <a href="#" class="link-click">some link text</a> <div id="small-text">here is the small text</div> //another text block </div> <script type="text/javascript">
<div id="some-div">
<a href="#" class="link-click">some link text</a>
<div id="small-text">here is the small text</div>
//another text block
</div>
<script type="text/javascript">
$('#some-div').click(function(){//some task goes here});
$('.link-click').click(function(){//some task goes here for link});
$('#small-text').click(function(){//some task goes here for small div});
</script>
下面是小文本
//另一个文本块
$('#some div')。单击(function(){//some task go here});
$('.link click')。单击(function(){//some task goes here for link});
$(“#小文本”)。单击(function(){//some task goes here for small div});
当我们点击div(id=somediv)弹出消息时,但是当我点击链接(class=linkclick)时,我需要运行另一个javascript函数。但问题是,当我点击linkclick时,它也会运行一些div函数。意味着单击两个函数即可运行
如何防止并发javascript函数执行。我也在使用jquery。
谢谢您可以使用它来避免事件在DOM树中冒泡
$('.link-click').click(function(e){
e.stopPropagation();
});