去掉字符串头尾的空格
$(document).ready(function(){
$("button").click(function () {
var str = " lots of spaces before and after ";
alert("'" + str + "'");
str = jQuery.trim(str);
alert("'" + str + "' - no longer");
});
Show Trim Example
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
This entry was posted on Wednesday, January 23rd, 2008 at 1:37 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Name (required)
Mail (will not be published) (required)
Website
Notify me of followup comments via e-mail