运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Window Object</h1> <h2>The addEventListener() Method</h2> <p>How to pass parameter values with the addEventListener() method.</p> <p>Click anywhere in the window to perform a calculation.</p> <p id="demo"></p> <script> let p1 = 5; let p2 = 7; window.addEventListener("click", function() { myFunction(p1, p2); }); function myFunction(a, b) { let result = a * b; document.getElementById("demo").innerHTML = result; } </script> </body> </html>