test
// 1,使用原生的字符串trim方法
var str = " ss ";
str.trim();
// 2 使用正則表達式將空白字符串替換成空字符串
str.replace (/^\s*|\s*$/g,'');
//3 如果瀏覽器不支持trim方法,可在代碼前加上
if(!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s*|\s*$/g,"");
}
}