In this case, you can use the JavaScript method replace():
'FoxRox'.replace(/(Rox)/, '<span>$1</span>');
To replace this with the entire document, you can try the following:
$(":contains('Rox')").html(function(i,o){
return o.replace(/(Rox)/g, '<span>$1</span>');
});
Please note that if your term is not "Rox", you need to change it in the above script.
source
share