源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> </head> <body> <p>點擊這個按鈕,來調用帶參數的函數。</p> <button onclick="myFunction('Harry Potter','Wizard')">點擊這里</button> <script> function myFunction(name,job){ alert("Welcome " + name + ", the " + job); } </script> </body> </html>
運行結果