Here the whole text inside the div get\'s red color. but I need only the \"bar\" word color to be changed
$("div:contains('bar')").each(function () { $(this).html($(this).html().replace("bar", "bar")); });
this will work surely
Please see Demo Here