event.namespace

event.namespace

event.namespaceReturns: String

Description: The namespace specified when the event was triggered.

  • version added: 1.4.3event.namespace

This will likely be used primarily by plugin authors who wish to handle tasks differently depending on the event namespace used.

Example:

Determine the event namespace used.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>event.namespace demo</title>
  <script src="https://code.jquery.com/jquery-1.10.2.js" rel="external nofollow" ></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>

Demo:

© The jQuery Foundation and other contributors
Licensed under the MIT License.
https://api.jquery.com/event.namespace

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部