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