javascript - input框怎么设置onKeypress事件只能输入数字,能兼容火狐,IE9的
PHPz
PHPz 2017-04-11 12:56:01
0
1
355

input框怎么设置onKeypress事件只能输入数字,能兼容火狐,IE9的

PHPz
PHPz

学习是最好的投资!

Antworte allen (1)
刘奇

http://runjs.cn/detail/pfojehd8

使用onInput()事件

oninput 是 HTML5 的标准事件,对于检测 textarea, input:text, input:password 和 input:search 这几个元素通过用户界面发生的内容变化非常有用,在内容修改后立即被触发,不像 onchange 事件需要失去焦点才触发。oninput 事件在主流浏览器的兼容情况如下:

    RunJS 
      // scripts function keypress(_this){ _this.value = _this.value.replace(/[^0-9]/g, ''); }
    Neueste Downloads
    Mehr>
    Web-Effekte
    Quellcode der Website
    Website-Materialien
    Frontend-Vorlage
    Über uns Haftungsausschluss Sitemap
    Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!