js中设置单词首字母大写

1 function ReplaceFirstUper(str)  
2 {     
3     str = str.toLowerCase();     
4     return str.replace(/\b(\w)|\s(\w)/g, function(m){  
5         return m.toUpperCase();  
6     });    
7 }  

 

posted on 2015-03-05 13:51  zikuai  阅读(238)  评论(0)    收藏  举报