
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- 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?
- Are jQuery events blocking?
- How we can prioritize jQuery events?
- How to implement a custom Python Exception with custom message?
- How to handle HTML5 media events using jQuery?
- How to raise jQuery Events and handle them?
- What are jQuery AJAX 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 custom JsonAdapter using Gson in Java?
- How to implement a custom AlertDialog View in Android?
- Which jQuery events do not bubble?
Advertisements