String.prototype.trim = function()
{
return this.replace(/(^/s*)|(/s*$)/g, '');
}
或
function trim(str)
{
return String(str).replace(/(^/s*)|(/s*$)/g,"");
}
String.prototype.trim = function()
{
return this.replace(/(^/s*)|(/s*$)/g, '');
}
或
function trim(str)
{
return String(str).replace(/(^/s*)|(/s*$)/g,"");
}