日期:2014-05-16 浏览次数:20370 次
<script language="javascript"> String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } var str = " b "; //before trim alert(str.length); //after trim alert(str.trim().length); </script>