Change font color back to default

Change font color back to default

I have a function that checks to see if the word the user types in a text area is equal to an element that is stored in an array. If it is a match then it changes the font color to blue. I have this part working however, what I need to get working is making the font color change back to black after the font color changes to clue. Here is the code that I have so far.

I'm not very skilled with JQuery either so sorry if anything is programmed not the best way lol.

  1.  var re = new RegExp("\\b" + word + "\\b", "gi");
  2.                     $container.contents().each(function () {
  3.                         if (this.nodeType === 1) {
  4.                             wrapLinesForKeyword($(this), word);
  5.                         } else {
  6.                             var text = $(this).text();
  7.                             //var text = $.trim(this)
  8.                             jQuery.trim(text);
  9.                             console.log(text);
  10.                             var testStr = jQuery.trim(text);
  11.                             if (testStr.match(re)) $(this).replaceWith(function () {
  12.                                 
  13.                                 return testStr = '<span style="color:blue">' + word + '</span>';

  14.                             })
  15.                             moveCaretToEnd(document.getElementById('my_text'));
  16.                             
  17.                         }
  18.                     })

I've tried adding these after the function to try and set the font color back to black but no  luck..

  1. $(lastWord).css("color", "black");
  2. $('#my_text').css("color", "black");
$('#my_text') is the name of the text area... I'd greatly appreciate if anybody could help me out in figuring out a solution to this.