首页 > 编程语言 > 详细

JavaScript 使用HTML DOM的oninput事件,实时监听value值变化

时间:2017-03-09 13:38:30      阅读:417      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>

<p>该实例演示了如何使用 addEventListener() 方法向 input 元素中添加 "oninput" 事件。</p>
<p>向文本框中尝试输入即可触发事件。</p>
输入您的名字: <input type="text" id="myInput" value="Mickey">
<script>
document.getElementById("myInput").addEventListener("input", myFunction);
function myFunction() {
    alert("input 输入框值已发生变化。");
}
</script>

</body>
</html>

感谢菜鸟教程runoob.com

JavaScript 使用HTML DOM的oninput事件,实时监听value值变化

原文:http://www.cnblogs.com/pangpanghuan/p/6525053.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!