您好,欢迎访问一九零五行业门户网

js字母大小写转换实现方法总结_javascript技巧

tolocaleuppercase 方法
返回一个字符串,其中所有的字母字符都被转换为大写,同时适应宿主环境的当前区域设置。
stringvar.tolocaleuppercase( )
必选的 stringvar 引用是一个 string 对象,值或文字。
说明
tolocaleuppercase 方法转换字符串中的字符,同时适应宿主环境的当前区域设置。在大多数情况下,其结果与利用 touppercase 方法所得到的结果是一样的。然而,如果语言规则与常规的 unicode 大小写映射方式冲突,那么结果就会不同。
tolocalelowercase 方法
返回一个字符串,其中所有的字母字符都被转换为小写,同时考虑到宿主环境的当前区域设置。
stringvar.tolocalelowercase( )
必选的 stringvar 引用是一个 string 对象,值或文字。
说明
tolocalelowercase 方法转换字符串中的字符,同时适应宿主环境的当前区域设置。在大多数情况下,其结果与利用 tolowercase 方法所得到的结果是一样的。然而,如果语言规则与常规的 unicode 大小写映射方式冲突,那么结果就会不同。
tolowercase 方法
返回一个字符串,该字符串中的字母被转换为小写字母。
strvariable.tolowercase( )
string literal.tolowercase( )
说明
tolowercase 方法对非字母字符不会产生影响。
下面的示例演示了 of the tolowercase 方法的效果:
var strvariable = this is a string object;
strvariable = strvariable.tolowercase( );
在执行上一条语句后 strvariable 的值为:
this is a string object
touppercase 方法
返回一个字符串,该字符串中的所有字母都被转化为大写字母 。
strvariable.touppercase( )
string literal.touppercase( )
说明
touppercase 方法对非字母字符不会产生影响。
示例
下面的示例演示了 touppercase 方法的效果:
var strvariable = this is a string object;
strvariable = strvariable.touppercase( );
在执行上一条语句后 strvariable 的值为:
this is a string object
复制代码 代码如下:
function upperfirstletter(str)  
{  
    return str.replace(//b/w+/b/g, function(word) {  
                           return word.substring(0,1).touppercase( ) +  
                                  word.substring(1);  
                         });
}
其它类似信息

推荐信息