- 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.data Property
The event.data property in jQuery contains the optional data passed to an event method when the current executing handler is bound.
Syntax
The syntax is as follows −
event.data
Example
Let us now see an example to implement the jQuery event.data 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").each(function(i){ $(this).on("click", {a:i}, function(event){ alert("Line " + event.data.a); }); }); }); </script> </head> <body> <h2>Demo Heading</h2> <p>This is the 1st paragraph.</p> <p>This is the 2nd paragraph.</p> <span>Click on any of the p element above</span> </body> </html>
Output
This will produce the following output −
Click on any of the p element −
Advertisements