Client has asked for just the /
of his site to be red... Throughout the entire site!
Do I have to add spans around each /, or is there an easier way?
Client has asked for just the /
of his site to be red... Throughout the entire site!
Do I have to add spans around each /, or is there an easier way?
Hope this sample helps. I found it in SO. You can replace the ®
with the html code of slash /
$(document).ready(function() {
$('*').each(function() {
var n = $(this).html().replace(
new RegExp('®','g'),
'<sup>®</sup>'
).replace(
new RegExp('®','g'),
'<sup>®</sup>'
);
$(this).html(n);
});
});
You could try following jQuery script:
$('body').html($('body').html()
.replace(/\/(?=[^>]*<)/gi, '<span style="color:red">/</span>'));
It simply wraps all slashes that are not inside tags with span.
Check how fast it is for your site, I believe it could be usable.
Here is a FIDDLE to demonstrate that using the lookahead (?=[^>]*<)
is important to prevent matches inside tags <>
to be replaced. Try removing it and resulting HTML will be broken.
Can't be done with css alone. Check this Link for how to do it with javascript
You have to wrap each occurrence of the character inside span
markup or other suitable markup. (Actually, <font color=red>/</font>
would work, too.) You can however do this dynamically client-side, if this sounds more suitable (you would have client-side JavaScript that traverses the document tree and does the wrapping).
Note: This won’t apply to content in elements that have plain text as declared content, such as option
elements. Inside them, individual characters cannot be styled differently from other content of the element.