I\'m trying to do something similar to this thread https://stackoverflow.com/a/3471258/2117845 and I think I want something like Harmen posted with the jquery code and said
I modified the code from Greg Dean's answer in a related question.
I would call this algorithm an educated guess at best since it's not actually evaluating English capitalization rules. You'll probably need to add more words to the noCaps list for better accuracy.
JS
var ele = $('p');
ele.text(toProperCase(ele.text()));
function toProperCase(str)
{
var noCaps = ['of','a','the','and','an','am','or','nor','but','is','if','then',
'else','when','at','from','by','on','off','for','in','out','to','into','with'];
return str.replace(/\w\S*/g, function(txt, offset){
if(offset != 0 && noCaps.indexOf(txt.toLowerCase()) != -1){
return txt.toLowerCase();
}
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
HTML
THE QUICK BROWN FOX IS ABOUT TO JUMP OVER THE FENCE