jQuery API

event.namespace

event.namespace Returns: 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>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  
<button>display event.namespace</button>
<p></p>

<script>
$("p").bind("test.something", function(event) {
  alert( event.namespace );
});
$("button").click(function(event) {
  $("p").trigger("test.something");
});  
</script>

</body>
</html>

Demo:

Support and Contributions

Need help with event.namespace or have a question about it? Visit the jQuery Forum or the #jquery channel on irc.freenode.net.

Think you've discovered a jQuery bug related to event.namespace? Report it to the jQuery core team.

Found a problem with this documentation? Report it to the jQuery API team.

* All fields are required
  • http://twitter.com/mateus_souzaweb Mateus Souza

    The result is correct? undefined…

  • http://twitter.com/marcalj Marçal Juan LLaó

    You need to reload cache (Ctrl+F5) to update “http://code.jquery.com/jquery-latest.min.js” content.

  • http://98.ru/ George

    Unfortunately such eccentricities are not working:

    $(“p”).bind(“mouseover.wewee”, function(event) {
    alert( event.namespace );

  • http://twitter.com/theonlywoj John Wojtowicz

    Looks like this works in Firefox (3.6) and fails in Chrome

  • http://twitter.com/bobmoff Fille

    Does not work in either Chrome or Firefox for me. I have refreshed and cleared cache in every possible way.

  • http://twitter.com/bobmoff Fille

    Does not work in either Chrome or Firefox for me. I have refreshed and cleared cache in every possible way.