jQuery event.data Property

Last Updated:

jQuery event.data Property

The jQuery event.data property contains the optional object of data passed to an event method when the current executing handler is bound.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery event.data Property</h1> <p>Click on this paragraph</p> <p>Click on this paragraph</p> <p>Click on this paragraph</p> <script> $(document).ready(function(){ $("p").each(function(i){ $(this).on("click", {x:i}, function(event){ console.log("Paragraph Number: " + $(this).index() + " \nParagraph has data: " + event.data.x); }); }); }); </script> </body> </html>

Syntax

event.data;

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
event.dataYesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author