Javascript examples for DOM:Document addEventListener
Document addEventListener() Method - Pass parameter values when using the addEventListener() method
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var p1 = 5; var p2 = 7; document.addEventListener("click", function() { myFunction(p1, p2); });// w ww .ja v a 2 s.co m function myFunction(a, b) { var result = a * b; document.getElementById("demo").innerHTML = result; } </script> </body> </html>