如何将每个单词的首字母大写,就像一个2个单词的城市?
2022-08-30 00:17:23
我的JS在城市有一个词时做得很好:
- cHIcaGO ==> 芝加哥
但是当它是
- 圣地亚哥==>圣地亚哥
如何让它成为圣地亚哥?
function convert_case() {
document.profile_form.city.value =
document.profile_form.city.value.substr(0,1).toUpperCase() +
document.profile_form.city.value.substr(1).toLowerCase();
}