var str = "border-bottom-color";
function test(str){
var arr = str.split("-");//用split()函数来进行分割字符串arr里面包括【border,bottom,color】
for(var i=1;i<arr.length;i++){//从数组的第二项开始循环,charAt(0)找到第一个字母。substring(1)截掉第一个字母。
arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].substring(1);//循环之后把得到的字符赋给arr。【border,Bottom, Color】
alert(arr[i]);
}
return arr.join("");//用join方法来拼接,空拼接。就变成borderBottomColor
}
alert(test(str));
toLowerCase():用于把字符串转换为小写。
toUpperCase() 方法用于把字符串转换为大写。
charAt() 方法可返回指定位置的字符。
第一个字符位置为 0, 第二个字符位置为 1,以此类推.