在我的网站中,有很多页面和内容。 现在我想在网站加载时替换所有页面中的一个单词。
最佳答案
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>
关于javascript - 我想在网站加载时替换所有页面中的一个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38995077/