web点前端

jquery 监听input输入值事件

  1. <html>  
  2.     <head>  
  3.     <title></title>      
  4.     <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>  
  5.     </head>  
  6.     <script type="text/javascript">  
  7.         $(function(){  
  8.             //IE  
  9.             if($.browser.msie){  
  10.                   $("#sno").get(0).attachEvent("onpropertychange",function (o){  
  11.                            alert(o.srcElement.value);  
  12.                     });  
  13.             //非IE  
  14.             }else{  
  15.             $("#sno").get(0).addEventListener("input",function(o){  
  16.                     alert(o.target.value);  
  17.                 },false);  
  18.             }  
  19.     });      
  20.     </script>  
  21.     <body>  
  22.         <input id="sno" value="">      
  23.     </body>  
  24.       
  25. </html>   

posted on 2014-11-24 15:24  web点前端  阅读(1539)  评论(0编辑  收藏  举报

导航