![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
$.fn.onlyNum = function () { $(this).keypress(function (event) { var eventObj = event || e; var keyCode = eventObj.keyCode || eventObj.which; if ((keyCode >= 48 && keyCode <= 57) || ((keyCode == 8 || keyCode == 46))) return true; else return false; }).focus(function () { //禁用输入法 this.style.imeMode = 'disabled'; }); };