function iGetInnerText(testStr) { var resultStr = testStr.replace(/\ +/g, ""); //去掉空格 resultStr = testStr.replace(/[ ]/g, ""); //去掉空格 resultStr = testStr.replace(/[\r\n]/g, ""); //去掉回车换行 return resultStr; }
var testStr=" sssss vvvvv "; var result=iGetInnerText(testStr);