js 去掉前后空格

前后去空格

return str.replace(/(^s*)|(s*$)/g, ""); 

全部去空格

$("#panelbody").text().replace(/s/g, "")
原文地址:https://www.cnblogs.com/CyLee/p/5558500.html