For a div that appears multiple times in your HTML :
<div class="myclass">abc</div>
<div class="myclass">abc def</div>
...
How can I achieve the replacement of "abc" for all the occurrences ? (I found resources to replace the first occurrence but not the rest)
This is my code with javascript method
<script>
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
oldText = document.getElementsByClassName("myclass").innerHTML;
for (i = 0; i<oldText.length; i++){
newText = oldText[i].innerHTML;
newText = newText.replace(/abc/g, "123");
oldText[i].innerHTML = newText;
});
</script>
.innerHTMLfromdocument.getElementsByClassName("myclass")