You can use the text
method and pass a function that returns the modified text, using the native String.prototype.replace
method to perform the replacement:
$(".text_div").text(function () {
return $(this).text().replace("contains", "hello everyone");
});
Here’s a working example.