在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" />
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>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2021-09-07
猜你喜欢
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
  • 2021-11-10
相关资源
相似解决方案