Is it possible to lessen the code or recreate similar code with same function with this: Fiddle here.Thanks
$(".addcolor:contains('red')").html(function(_, html) {
return html.replace(/(red)/g, '<span class="red">$1</span>')
});
$(".addcolor:contains('blue')").html(function(_, html) {
return html.replace(/(blue)/g, '<span class="blue">$1</span>')
});
$(".addcolor:contains('green')").html(function(_, html) {
return html.replace(/(green)/g, '<span class="green">$1</span>')
});
The function of the code is to replace a specific text with span . How about to apply the css directly with the jquery code?