JSFiddle - React, Tailwind, and code Playground
by Walter Rumsby
HTML
<input id="num" value="0">
JavaScript
(function($) {
$.fn.numeric = function() {
var prototype = this.prototype || this.__proto__ || this,
oVal = prototype.val;
prototype.val = function(value) {
var params = [];
if (typeof value !== 'undefined') {
if (isNaN(value)) {
return;
}
params.push(+value);
}
return oVal.apply(this, params);
}
return this;
};
})(jQuery);
var o = $('#num').numeric();
debugger;
o.val(2);
o.val('hi');