- 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
How to implement custom events in jQuery?
Custom event means you can create your own events in jQuery. For example, create a custom event to fire an alert box on pressing any key on the keyboard.
Example
You can try to run the following code to learn how to create a custom event,
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('textarea').bind("enterKey",function(e){ alert("You have pressed Enter key!"); }); $('textarea').keyup(function(e){ if(e.keyCode == 13) { $(this).trigger("enterKey"); } }); }); </script> </head> <body> <textarea rows="2" cols="20"> </textarea> </body> </html>
- Related Articles
- How to bind jQuery events on elements generated through other events?
- How to fire jQuery events with setTimeout?
- How to store and reproduce jQuery events?
- How to implement a custom Python Exception with custom message?
- What are custom events in JavaScript?
- How to handle HTML5 media events using jQuery?
- How we can prioritize jQuery events?
- How to create a custom jQuery Plugin?
- How to write a custom jQuery plugin?
- How to implement custom FieldNamingStrategy using Gson in Java?
- How to implement a custom AlertDialog View in Android?
- How to implement custom JsonAdapter using Gson in Java?
- How to use jQuery touch events plugin for mobiles?
- Are jQuery events blocking?
- How to implement custom JSON serialization with Gson in Java?

Advertisements