/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var template: '$1<span class="highlight">$2</span>$3'; var pattern = new RegExp('(>[^<.]*)(' + keywords + ')([^<.]*)', "ig"); var content = $('body').html(); $('body').html(content.replace(pattern, template));
URL: http://www.techtricky.com/highlight-text-with-jquery/