stopImmediatePropagation()方法停止执行其余的处理程序。此方法还通过调用event.stopPropagation()来停止冒泡。
您可以使用 event.isImmediatePropagationStopped()来了解是否曾经(在该事件对象上)调用过此方法。
event.stopImmediatePropagation()
以下是一个简单的示例,简单说明了此方法的用法-
<html> <head> <title>The jQuery Example</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $("div").click(function(event){ alert("1 - This is : " + $(this).text()); //Comment the following to see the effect. event.stopImmediatePropagation(); }); //This won't be executed. $("div").click(function(event){ alert("2 - This is : " + $(this).text()); }); }); </script> <style> div{ margin:10px;padding:12px; border:2px solid #666; width:160px;} </style> </head> <body> <p>Click on any box to see the result:</p> <div id="div1" style="background-color:blue;"> BOX 1 </div> <div id="div2" style="background-color:red;"> BOX 2 </div> </body> </html>
这将产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/jquery/events-stopimmediatepropagation.html
来源:LearnFk无涯教程网
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Spring Boot与Kubernetes云原生微服务实践 -〔杨波〕