Hacked way:
<div>John Resig</div> <div>George Martin</div> <div>Malcom John Sinclair</div> <div>J. Ohn</div> <script> $("div:contains('John')").each(function(i,e){ var $this = $(this); var html = $this.html() .replace(/John/g,'<span style="text-decoration:underline;">John</span>'); $this.html(html); }); </script>
As seen here
But be careful, if you have "John" in the link or title tag, this will also replace these instances. eg.
<div><img src="..." title="This is John" /></div>
becomes:
<div><img src="..." title="This is <span style="text-decoration:underline;">John</span>" /></div>
(undesirable if I thought)
source share