<!DOCTYPE html>        
<html lang="en">        
<head>        
    <meta charset="UTF-8">        
    <title>js 去掉字符串中的非数字</title>      
    <style type="text/css">  
    </style>   
</head>        
<body>  
  <input type="text" >
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>  
  <script type="text/javascript">  
    $('#m-code').on('keyup', function() {
      var val = $(this).val();
      val = val.replace(/[^0-9]/ig,"");
      $(this).val(val);
    });
  </script>  
</body>        
</html> 

相关文章:

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