As a mere example, I want to apply the class “fancy” to all occurrences of the sign “&” in the document.
The CSS:
.fancy { font-style: italic; }
So a text that looks like this:
Ben & Jerry's
would be manipulated by jquery to this:
Ben <span class="fancy">&</span> Jerry's
Is there a function to target specific words/phrases/letters like this?
This isn’t something that jQuery is generally helpful with–it works more at the node level than the text/html level. However, this might help (source):
Obviously if you can restrict the initial search to something better than all paragraphs, it’d perform better. You should also test it to see if the
:containsfilter actually helps.It’s not pretty but it seems to work.