- //js里是没有trim()方法,自定义一个js函数用来去除字符串两端的空格
- String.prototype.trim = function()
- {
- return this.replace(/(^s*)|(s*$)/g, "");
- }
- //去除前面的空格
- String.prototype.LTrim = function()
- {
- return this.replace(/(^s*)/g, "");
- }
- //去除后面的空格
- String.prototype.RTrim = function()
- {
- return this.replace(/(s*$)/g, "");
- }
转载于:https://blog.51cto.com/yaomingkai/1125741
最后
以上就是深情雪糕最近收集整理的关于js去除两端空格的全部内容,更多相关js去除两端空格内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复