编辑下面的代码:【加编码】
<html> <body> <p>该实例演示了如何使用 HTML DOM 向 input 元素中添加 "oninput" 事件。</p> <p>向文本框中尝试输入即可触发事件。</p> 输入您的名字: <input type="text" id="myInput" value="Mickey"> <script> document.getElementById("myInput").oninput = function() {myFunction()}; function myFunction() { alert("input 输入框值已发生变化。"); } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂