如何在 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>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP