Skip to content

Instantly share code, notes, and snippets.

@codemaniac
Created July 13, 2012 08:47
Show Gist options
  • Save codemaniac/3103704 to your computer and use it in GitHub Desktop.
Save codemaniac/3103704 to your computer and use it in GitHub Desktop.
Javascript function to convert a string to Proper/Title case
(function($, undefined){
String.prototype.toProperCase = function () {
return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment