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>热门推荐
10 公司文案生日祝福语简短
11 孩子军训回家祝福语简短
12 水晶婚夫妻祝福语简短
13 宝宝新年祝福语大全简短
14 老师新婚快乐祝福语简短
15 给生病公公祝福语简短
16 60岁长辈祝福语简短
17 写给兄弟的祝福语简短
18 出院家庭花束祝福语简短