Finding a comma and replacing with span tags to style the text differently
I am trying to write a script that replaces a comma in a different font. Nice commas.
<!-- CSS -->
.nicecom {
font-family: 'Freight Big Pro';
}
function initNiceCom() {
$('#container').text(function (index, text) {
return text.replace(',', '<span class="nicecom">,</span>');
});
}
I am searching the #container div for a "," and then replacing it by wrapping around <span></span> tags.
My script has no effect. Any ideas how I can achieve this?