Is there a built in way with jQuery to "title case" a string? So given something like bob smith, it turns into "Bob Smith"?
You don't need jQuery for this; it can be accomplished using the native .replace() method:
.replace()
function toTitleCase(str) { return str.replace(/(?:^|s)w/g, function(match) { return match.toUpperCase(); }); } alert(toTitleCase("foo bar baz")); // alerts "Foo Bar Baz"
1.4m articles
1.4m replys
5 comments
57.0k users