I have a string that is in ALL caps originally and I want it to be title case:
THIS IS MY STRING WHY AM I YELLLING?
And I want it to be:
This Is My String Why Am I Yelling?
I can't use css text-transform:capitalize when the letters are in CAPS initially. So I know I have to use JS. I tried this, which works but I'm not sure it's very efficient:
$('.location').each(function () {
var upper = $(this).html();
var lower = upper.toLowerCase();
$(this).replaceWith(lower);
});
And now that my letters are actually lowercase, I use CSS text-transform:capitalize
.
Is there a more efficient way to do this? (I'm already using jQuery on the site, so that's why I've used it above.)
Thanks!