如何單擊呼叫 JavaScript 函式?
如要在 JavaScript 中單擊某個按鈕時呼叫某個函式,請使用 onclick。嘗試執行以下程式碼以在 JavaScript 中單擊 onclick 按鈕呼叫一個函式 −
示例
<html>
<head>
<script>
function sayHello() {
document.write ("Hello there!");
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type = "button" onclick = "sayHello()" value = "Say Hello">
</form>
<p>Use different text in write method and then try...</p>
</body>
</html>
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP