非标准
该特性是非标准的,请尽量不要在生产环境中使用它!

 trimRight() 方法从一个字符串的右端移除空白字符。

语法

string.trimRight()

描述

trimRight方法移除原字符串右端的连续空白符并返回,trimRight方法并不会直接修改原字符串本身.

示例

例子: 使用trimRight

下面的例子输出了小写的字符串"   foo":

var str = "   foo  ";

alert(str.length); // 8

str = str.trimRight();
alert(str.length); // 6
document.write( str );

Specifications

无相关规范。Implemented in JavaScript 1.8.1.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 3.5 (1.9.1) 未实现 ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? (Yes) ? ? ?

相关链接

文档标签和贡献者

此页面的贡献者: teoli, Ende93, xgqfrms-GitHub, ziyunfei
最后编辑者: teoli,