我有以下jQuery
shell工作:
$('.jq_noSpaces').on('change',function(){ alert('you changed the value in the Box'); });
我的表单属性是id =“username”name =“username”
如何使用以下jQuery替换函数自动更改从输入字段中删除空格?
str.replace(/\s+/g,'');
谢谢
解决方法
您可以使用以下语法:
$(this).val($(this).val().replace(/\s+/g,''));
在事件处理程序内部.