当前位置: 移动技术网 > IT编程>开发语言>JavaScript > js坚持不懈之18:trim()方法

js坚持不懈之18:trim()方法

2019年02月21日  | 移动技术网IT编程  | 我要评论

trim()方法,类似python中的strip(),用去去除字符串对象前后的空格。

<!doctype html>

<html>

<body>
<script>
var s = "       afsdf           ";
document.write("|" + s + "|" + "<br>");
var s2 = s.trim();
document.write("|" + s2 + "|" + "<br>");
</script>
</body>
</html>

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网