Please note, this is a STATIC archive of website www.tutorialrepublic.com from September 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Assigning Multiple Event Listeners on a Single Event</title> </head> <body> <button id="myBtn">Click Me</button> <script> // Defining custom functions function firstFunction() { alert("The first function executed successfully!"); } function secondFunction() { alert("The second function executed successfully"); } // Selecting button element var btn = document.getElementById("myBtn"); // Assigning event listeners to the button btn.addEventListener("click", firstFunction); btn.addEventListener("click", secondFunction); </script> </body> </html>