![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1
<!
DOCTYPE HTML PUBLIC
"
-//W3C//DTD HTML 4.01 Transitional//EN
"
2 " http://www.w3.org/TR/html4/loose.dtd " >
3 < html >
4 < head >
5 < meta http - equiv = " Content-Type " content = " text/html; charset=gb2312 " >
6 < title > 无标题文档 </ title >
7 < script src = " jquery-1.4.2.min.js " type = " text/javascript " ></ script >
8 < script language = " javascript " type = " text/javascript " >
9 var sString = " 1234567890 " ;
10 sString = $.trim(sString);
11 alert( sString.length);
12
13
14 </ script >
15 </ head >
16
17 < body >
18 </ body >
19 </ html >
20
2 " http://www.w3.org/TR/html4/loose.dtd " >
3 < html >
4 < head >
5 < meta http - equiv = " Content-Type " content = " text/html; charset=gb2312 " >
6 < title > 无标题文档 </ title >
7 < script src = " jquery-1.4.2.min.js " type = " text/javascript " ></ script >
8 < script language = " javascript " type = " text/javascript " >
9 var sString = " 1234567890 " ;
10 sString = $.trim(sString);
11 alert( sString.length);
12
13
14 </ script >
15 </ head >
16
17 < body >
18 </ body >
19 </ html >
20
以上主要实现去前后空格的方法。