给你的Javascript中的String加上Trim的功能!
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
// 例子
var s = " leading and trailing spaces ";
window.alert(s + " (" + s.length + ")");
s = s.trim();
window.alert(s + " (" + s.length + ")");