Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
Created December 23, 2019 12:25
Show Gist options
  • Save luislobo14rap/e44c48b8a51b68058ec45bf05d08c737 to your computer and use it in GitHub Desktop.
Save luislobo14rap/e44c48b8a51b68058ec45bf05d08c737 to your computer and use it in GitHub Desktop.
capitalizeCase.js
// capitalizeCase.js v1
function capitalizeCase(text){
return text.toLowerCase().replace(/\b[a-z]/g, function(value){
return value.toUpperCase();
});
};
String.prototype.capitalizeCase = function(){
return capitalizeCase(this.toString());
};
if(typeof jQuery != 'undefined'){
jQuery.fn.extend({
capitalizeCase: function(){
return capitalizeCase($(this).text());
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment