1 2 3 4 5 6 7 8 9 10 11 12 13
| function convertToCamelCase(cssProperty) { if (cssProperty[0] == "-") { cssProperty = cssProperty.slice(1); } return cssProperty.replace(/-([a-z])/g, function (match, letter) { return letter.toUpperCase(); }); }
console.log(convertToCamelCase("font-size")); console.log(convertToCamelCase("-webkit-text-stroke"));
|