js去除字符串中的空格

function trim(strToTrim) { return strToTrim.replace(/^\s+|\s+$/g, "") }
原文地址:https://www.cnblogs.com/xinzhuangzi/p/4100662.html