String Replace All
javascript - replace all occurrences in a string
by Faruk Arıgün
HTML
<div id="1">SEO</div>
<div id="2">SEO</div>
<div id="3">SEOgibi</div>
JavaScript
var divs = document.getElementsByTagName("div");
for(var i = 0; i < divs.length; i++){
//do something to each div like
strMod = divs[i].innerHTML;
if (strMod === "SEO") {
// block of code to be executed if the condition is true
str = "<a href=\"https:\/\/rapidseo.net\">Rapidseo<\/a>";
divs[i].innerHTML = str;
}
}