I have a simple javascript function which replaces the “y” character within a any span.certain_class with an “i”:
$(document).ready(function() {
$('span.certain_class').each(function() {
$(this).text($(this).text().replace(/y/ig, function(s) {
return (s === 'Y' ? 'I' : 'i');
}));
});
});
The problem I’m having is that I want to wrap the replaced character with a span:
<span>i</span>
When I do this, the browser prints out the tags as strings, instead of parsing them as HTML code.
Can anyone help me solve this?
Try
That will make the result parse as HTML rather than plain text.