-3

I have word "john" used many times in my document which I want to replace with "mike". How can I achieve that using Jquery?

Valamor
  • 1
  • 2

2 Answers2

0
$("body").text(function () {
    return $(this).text().replace("john", "mike"); 
});

This would work if you need to change any text found in the body element.

Monroy
  • 420
  • 5
  • 19
0

Something like that:

var replaced = $("body").html().replace(/John/g,'Mike');
$("body").html(replaced);

Source: Replace text in HTML page with jQuery

Community
  • 1
  • 1
Michael
  • 1,063
  • 14
  • 32