下面一起来学习怎么样去除字符串左右两边的空格。
过滤前:

过滤后:

用户名">
CSS代码:
Box-sizing:border-Box;border:1px solid blue;}
input[type="button"]{width:50%;background:blue;}
@media only screen and (max-width: 415px) {
.main{width:100%;Box-sizing:border-Box;}
}
js部分:
rule.onclick = function (){
userName.value = userName.value.replace(regexEmpty,''); //正则替换
console.log(userName.value);
}</pre>
以上这篇去除字符串左右两边的空格(实现代码)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。