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 and check your console.</p> <p>Click on this paragraph and check your console.</p> <p>Click on this paragraph and check your console.</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>
OUTPUT
×

Save as Private