How can I make all question marks, for example in text, be color-specific?

Is there a way, for example, to make every question mark, exclamation mark or comma, etc. fit a specific style, without having to wrap each one in div

or span

for that style

+3


source to share


2 answers


One way is to dynamically add span

with a specific class to all question marks. You can do this with a PHP function str_replace()

like.



+2


source


Here's an example of what I said about using regular expressions. You can also add additional punctuation to the expression:

string = $('p').text();
string = string.replace(/(['&.!,])/g,"<span>$1</span>");
$('p').html(string);

      



FIDDLE

+1


source







All Articles