jQuery on()
with custom data
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>//from w w w.j a v a 2 s.c o m <script> function handlerName(event) { document.getElementById("demo").innerHTML = event.data.msg; } $(document).ready(function(){ $("p").on("click", {msg: "Hi!"}, handlerName) }); </script> </head> <body> <p id="demo"></p> <p>Click me!</p> </body> </html>