Created
July 18, 2015 19:56
-
-
Save kier0/5d6578113745a2f36436 to your computer and use it in GitHub Desktop.
Wrap a certain character in a line of text in a span - to isolate and style. Example below is finding all the "i, I and ." in the text. ****NOTE**** Wordpress REMOVES backslashes needed to make a period read as a period and not a "wildcard". Must load this code in an external js file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(document).ready(function() { | |
| jQuery(".content-title p:contains('i')").html(function(_, html) { | |
| return html.replace(/(i)/g, '<span class="pink">$1</span>'); | |
| }); | |
| // Pink I's | |
| jQuery(".content-title p:contains('I')").html(function(_, html) { | |
| return html.replace(/(I)/g, '<span class="pink">$1</span>'); | |
| }); | |
| // Pink periods | |
| jQuery(".content-title p:contains('\.')").html(function(_, html) { | |
| return html.replace(/(\.)/g, '<span class="pink">.</span>'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment