Load this plugin. Then:
$("body *").replaceText( /&/gi, '<b class="ampersand">' + '&' + '</b>' );
Change the selector as needed. That one is pretty intense.
Now you have a class name you can use to style them specially.
.ampersand {
font-family: Baskerville, Some Other Cool Font, Serif;
font-style: italic;
}
Just a note, but the snippet is missing the HTML that surrounds the ampersand with an element with a class of ampersand.
I don’t think you’re escaping your HTML correctly in the example above..
Hi Chris !
Whouldn’t this become a problem when you have special unicode chars like ×, < or whatever ? Will it break those chars ?
JQuery
.highlight()
text plugin:http://jsfiddle.net/tovic/kfqJu/1/
Source: http://www.gotoquiz.com/web-coding/programming/javascript/highlight-words-in-text-with-jquery/