Javascript String capitalizeEachWord()

Description

Javascript String capitalizeEachWord()

String.prototype.capitalizeEachWord = function () {
    return this.replace(/\w\S*/g, function(txt) {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });//from  w  ww . j  ava 2 s. c o  m
}



PreviousNext

Related