js如何在字符串前面添加空格

JavaScript016

js如何在字符串前面添加空格,第1张

<SCRIPT LANGUAGE="JavaScript">

<!--

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, "")

}

//-->

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">

<!--

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, "")

}

//-->

</SCRIPT>