Javascript examples for DOM:Element addEventListener
Element addEventListener() Method - Pass parameter values when using the addEventListener() method
<!DOCTYPE html> <html> <body> <button id="myBtn">Test</button> <p id="demo"></p> <script> var p1 = 5; var p2 = 7; document.getElementById("myBtn").addEventListener("click", function() { myFunction(p1, p2); });// www.j a va 2s. c o m function myFunction(a, b) { var result = a * b; document.getElementById("demo").innerHTML = result; } </script> </body> </html>