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, "");}
var str=" helloworld ";
alert("----"+str.Ltrim()+"-----"); //去左边空格
alert("----"+str.Rtrim()+"-----"); //去右边空格
alert("----"+str.Trim()+"-----"); //两边空格都去空格
js 去空格处理
最新推荐文章于 2024-05-17 02:56:15 发布