Capitalize and color the first letter after a period in jquery
<p>I'm trying figure out how to color the first word after the period.</p>

<p>I worked out capitalizing the first letter, but now I need it be colored. I preferred to be the first letter "red".</p>

<pre><code>$(function () {
function capitalizeSentences(capText, capLock) {

    if (capLock == 1 || capLock == true) {
        capText = capText.toLowerCase();
    }

    capText = capText.replace(/\.\n/g, ".[-&lt;br&gt;-]. ");
    capText = capText.replace(/\.\s\n/g, ". [-&lt;br&gt;-]. ");
    var wordSplit = '. ';   

    var wordArray = capText.split(wordSplit);

    var numWords = wordArray.length;

    for (x = 0; x &lt; numWords; x++) {
        wordArray[x] = wordArray[x].replace(wordArray[x].charAt(0), wordArray[x].charAt(0).toUpperCase());
        if (x == 0) {
            capText = wordArray[x] + ". ";
        } else if (x != numWords - 1) {
            capText = capText + wordArray[x] + ". ";
        } else if (x == numWords - 1) {
            capText = capText + wordArray[x];
        }
    }
    capText = capText.replace(/\[-&lt;br&gt;-\]\.\s/g, "\n");
    capText = capText.replace(/\si\s/g, " I ");
    return capText;
}
//Capitalize After Period
$("#capitalizeAfterPeriod").click(function () {
    var txt = $('textarea#generator').val();
    txt = capitalizeSentences(txt, true);
    $('textarea#generator').val(txt).addClass('period');
});
});
</code></pre>
