如何在 onclick 事件中呼叫多個 JavaScript 函式?
要透過單擊事件來呼叫多項 JavaScript 函式,請使用分號,如下所示:
onclick="Display1();Display2()"
示例
<html> <head> <script> function Display1() { document.write ("Hello there!"); } function Display2() { document.write ("Hello World!"); } </script> </head> <body> <p>Click the following button to call the function</p> <form> <input type = "button" onclick = "Display1(); Display2()" value = "Result"> </form> </body> </html>
廣告