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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM