- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
jQuery event.namespace Property
The event.namespace property in jQuery is used to return the custom namespace when the event was triggered.
Syntax
The syntax is as follows −
event.namespace
Example
Let us now see an example to implement the jQuery event.namespace property −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on("custom.demoNamespace",function(event){ alert(event.namespace); }); $("p").click(function(event){ $(this).trigger("custom.demoNamespace"); }); $("button").click(function(){ $("p").off("custom.demoNamespace"); }); }); </script> </head> <body> <h2>Demo Heading</h2> <p>This is demo paragraph.</p> <p>This is demo paragraph.</p> <button>Remove namespace</button> <p>Click on any of the above paragraph</p> </body> </html>
Output
This will produce the following output −
Above, on clicking any of the p element −
Now, click the button “Remove Namespace”. After that, on clicking any of the p element, none of the alert box will generate.
Advertisements