JavaScript 中 oninput 事件有什麼用途?
當在輸入框中新增值時,就會發生 oninput 事件。你可以嘗試執行以下程式碼以瞭解如何在 JavaScript 中實現oninput事件 -
示例
<!DOCTYPE html>
<html>
<body>
<p>Write below:</p>
<input type = "text" id = "newInput" oninput = "inputFunc()">
<p id = "demo"></p>
<script>
function inputFunc() {
var a = document.getElementById("newInput").value;
document.write("Typed: " + a);
}
</script>
</body>
</html>
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言
C++
C#
MongoDB
MySQL
Javascript
PHP