js过滤前后空格

页面中添加代码

String.prototype.trim=function() {
    return this.replace(/(^\s*)|(\s*$)/g,'');
}

调用:title.trim()

 

posted @ 2016-01-29 16:19  zhjahch  阅读(694)  评论(0编辑  收藏  举报