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.
- var re = new RegExp("\\b" + word + "\\b", "gi");
- $container.contents().each(function () {
- if (this.nodeType === 1) {
- wrapLinesForKeyword($(this), word);
- } else {
- var text = $(this).text();
- //var text = $.trim(this)
- jQuery.trim(text);
- console.log(text);
- var testStr = jQuery.trim(text);
- if (testStr.match(re)) $(this).replaceWith(function () {
-
- return testStr = '<span style="color:blue">' + word + '</span>';
-
- })
- moveCaretToEnd(document.getElementById('my_text'));
-
- }
- })
I've tried adding these after the function to try and set the font color back to black but no luck..
- $(lastWord).css("color", "black");
- $('#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.