IE8的input兼容性问题

在chrome、firefox、IE9+都是支持input事件

 

在IE8中,单纯的input事件无法监听输入框中变化,需要与propertychange共用

 

测试代码如下:

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <script src="jquery-1.11.3.js"></script>
 6         <title></title>
 7     </head>
 8     <body>
 9         <input type="text" placeholder="请输入内容"/>
10         <input type="text" id="txtInput"/>
11         <script>
12             //IE9+、chrome、firefox
13             $("#txtInput").bind("input",function(e){  // propertychange
14                 alert(111);
15             });
16             //IE8-IE9
17             $("#txtInput").bind("input propertychange",function(e){
18                 alert("输入框有变化。。");
19             });
20         </script>
21     </body>
22 </html>

 

posted @ 2017-05-21 10:24  CodeProducter  阅读(2871)  评论(0编辑  收藏  举报