In my website, there have many page and content. Now I want to replace one word from all page when website is loaded.
Asked
Active
Viewed 121 times
1
-
2Refer to [this](http://stackoverflow.com/questions/5558613/javascript-replace-text-in-the-html-body) – Aakash Aug 17 '16 at 11:16
1 Answers
0
timer = setInterval(myFunction,100);
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var res = str.replace("hello", "hi");
document.getElementById("demo").innerHTML = res;
}
<p>Click the button to replace "hello" with "hello" in the paragraph below:</p>
<p id="demo">Visit hello!</p>

Jaydeep Gondaliya
- 331
- 6
- 16