I want to replace all the words that match with a variable in a string, but it doesn't work. I use this code:
var findStr = "hello hi, test, hi";
var textSearch = "hi";
findStr = findStr.replace(textSearch,'<span>'+textSearch+'</span>');
It has to change the color of hi
but only the first hi
changes, the second one doesn't.