jQuery on()
with your own event
<!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 va 2 s . c om*/ <script> $(document).ready(function(){ $("p").on("myOwnEvent", function(event, showName){ $(this).text(showName + "! hi!").show(); }); $("button").click(function(){ $("p").trigger("myOwnEvent", ["CSS"]); }); }); </script> </head> <body> <p>Click the button to attach a customized event on this p element.</p> <button>Trigger custom event</button> <p>Click the button to attach a customized event on this p element.</p> <p>Click the button to attach a customized event on this p element.</p> <p>Click the button to attach a customized event on this p element.</p> </body> </html>