Return to Snippet

Revision: 45575
at May 4, 2011 07:12 by sguduru


Updated Code
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));

Revision: 45574
at May 4, 2011 07:09 by sguduru


Initial Code
var template: '$1<span class="highlight">$2</span>$3';
var pattern = new RegExp('(>[^<.]*)(' + o.words + ')([^<.]*)', "ig");

var content = $('body').html();
$('body').html(content.replace(pattern, o.template));

Initial URL
http://www.techtricky.com/highlight-text-with-jquery/

Initial Description

                                

Initial Title
Highlight Search Terms on page using jQuery

Initial Tags
jquery, text

Initial Language
jQuery