- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does jQuery event namespace works?
The event.namespace property is used to return the custom namespace when the event was triggered.
Example
You can try to run the following code to learn how event namespace works and how to create and remove 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("custom.myNamespace",function(event){ alert(event.namespace); }); $("p").click(function(event){ $(this).trigger("custom.myNamespace"); }); $("button").click(function(){ $("p").off("custom.myNamespace"); }); }); </script> </head> <body> <p>Click me</p> <p>Click above to generate an alert box. Click the below button to remove namespace, which won’t generate an alert box.</p> <button>Click this button to remove namespace.</button> </body> </html>
- Related Articles
- How does jQuery Datepicker onchange event work?
- How does digital thermometer works?
- How to override jQuery event handlers?
- How does JavaScript focus() method works?
- How does Secure Hash Algorithm works?
- How does the MD5 Algorithm works?
- How would you unbind all jQuery events from a particular namespace?
- How to remove event handlers using jQuery?
- How to suppress jQuery event handling temporarily?
- How to handle jQuery AJAX success event?
- How does == operator works in Python 3?
- How does Constraint Layout works in android?
- How does DES works in Information Security?
- How does Steganography works in Information Security?
- How does Hibernate Second Level Cache Works?

Advertisements