/ Published in: jQuery
Find any instances of certain text in an element and modify it.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$("#main-div").html(function(i,text){ return text.replace("keyword", function(match){ return '<span class="red">' + match + '</span>'; }); });