最快捷最简单的方法是将字符串拆分为基于空格的数组,然后将其设置为第一个.
var theString = "hello world";
theString = theString.split(" ")[0];
alert(theString); // alerts "hello"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3587 次 |
| 最近记录: |