I am looking to highlight a 'SearchString' by replacing it with
<span style="background-color: yellow">SearchString</span>
within a targetString.
The SearchString varies, so I am wondering how I can make this happen.
This is what I have attempted so far -
var applyHighlighting = function (highlightableElements, productFilterKeyword) {
for(var i =0; i< highlightableElements.length; i++){
var regexp = new RegExp(productFilterKeyword, 'ig');
var replaceKeyWord = highlightableElements[i].innerHTML.match(regexp);
highlightableElements[i].innerHTML = highlightableElements[i].innerHTML.replace(regexp, '<span style="background-color: yellow">replaceKeyWord</span>');
}