Here the whole text inside the div get\'s red color. but I need only the \"bar\" word color to be changed
Solution with code snippet..
var text_change = 'bar';
$(document).ready(function () {
$("div:contains('"+text_change+"')").each(function () {
var regex = new RegExp(text_change,'gi');
$(this).html($(this).text().replace(regex, ""+text_change+""));
});
});
.red {
color:#008000;
}
this is a new bar and bar.