---
title: "javascript 去除字符串中空格的函数"
author: "ywg2008"
date: "2007-11-30T01:09:32Z"
tags: []
slug: "javascript"
draft: false
lastmod: "2007-11-30T01:09:32Z"
id: 144976
url: "https://gmf.iteye.com/blog/144976"
---

(1) 用display隐藏显示表格时不能在TR外面使用DIV，但是可以使用TBODY，

(2) javascript 去除字符串中空格的函数

 

01. // 去除左空格
02. function ltrim(s){
03. return s.replace( /^\\s\*/, "");
04. }
05. // 去右空格;
06. function rtrim(s){
07. return s.replace( /\\s\*$/, "");
08. }
09. // 去左右空格;
10. function trim(s){
11. return rtrim(ltrim(s));
12. }