I want to color all the words that I select in my input from the rows of the table. The line table contains a line of paragraphs.
The problem with this code, it just colors 1 word not all words for paragraphs, and it adds the word I want to color in before the paragraph for exp, if I have two paragraphs, it will color one word from each paragraph, and it will concatenate the word I chose to color it at the beginning of the second paragraph.
my javascript code is:
var word ='pregnant';
var a = row["Abstract"].substring(0, row["Abstract"].indexOf(word));
var b = row["Abstract"].substring(row["Abstract"].indexOf(word) + word.length);
HTML:
'<span style="color: black;">'+ a +'</span>' + '<span style="color: red;">'+ word +'</span>' + b
source
share