Javascript examples for DOM:Element addEventListener
Element addEventListener() Method - Add two click events on the same <button> element:
<!DOCTYPE html> <html> <body> <button id="myBtn">Test</button> <script> var x = document.getElementById("myBtn"); x.addEventListener("click", myFunction); x.addEventListener("click", someOtherFunction); function myFunction() {//from w w w . jav a 2s . co m console.log("Hello World!") } function someOtherFunction() { console.log("This function was also executed!") } </script> </body> </html>