Javascript examples for jQuery Method and Property:event.namespace
The event.namespace property returns the custom namespace when the event was triggered.
Parameter | Require | Description |
---|---|---|
event | Required. | The event parameter comes from the event binding function |
The following code shows how to Add and remove a custom namespace:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on("click.myId", function(){ $(this).slideToggle();/*from w w w. ja v a 2 s .c o m*/ }); $("button").click(function(){ $("p").off("click.myId"); }); }); </script> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <p>Click any p element to make it disappear.</p> <button>Remove the click.myId namespace for all p elements</button> <br><br> </body> </html>