当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JQuery event.namespace用法及代码示例


用法
event.namespace => String

说明:触发事件时指定的命名空间。

  • 添加的版本:1.4.3event.namespace

这可能主要由希望根据所使用的事件命名空间以不同方式处理任务的插件作者使用。

例子:

确定使用的事件命名空间。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>event.namespace demo</title>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
<button>display event.namespace</button>
<p></p>
 
<script>
$( "p" ).on( "test.something", function( event ) {
  alert( event.namespace );
});
$( "button" ).click(function( event ) {
  $( "p" ).trigger( "test.something" );
});
</script>
 
</body>
</html>

演示:

相关用法


注:本文由纯净天空筛选整理自jquery.com大神的英文原创作品 event.namespace。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。