x
 
<!DOCTYPE html>
<html>
<body>
<p>本例使用 addEventListener() 方法将 "input" 事件附加到 input 元素。</p>
<p>请在文本字段中写一些内容来触发函数。</p>
Enter name: <input type="text" id="myInput" value="Mickey">
<script>
document.getElementById("myInput").addEventListener("input", myFunction);
function myFunction() {
  alert("The value of the input field was changed.");
}
</script>
</body>
</html>