function cssStyle2DomStyle(sName) { var res = '' var first = true sName.replace(/(\w+)/g, function () { console.log(arguments[0]) if (first) { res += arguments[0] first = false } else { res += (arguments[0].slice(0, 1)).toUpperCase() + arguments[0].slice(1) } }) return res } console.log(cssStyle2DomStyle('font-size'))