I am trying to change this jquery to pure javascript:
var subContainerElement = $('#' + mainContainerId).find('#' + subContainer);
$(window).bind("load", function () {
$(subContainerElement).html(function (index, text) {
newParagraphText = text.replace("aaa", "bbb");
return newParagraphText;
});
});
Javascript:
var subContainerElement = mainContainer.getElementsByClassName(subContainer)[0];
document.addEventListener("DOMContentLoaded", function(event) {
mainContainer.getElementsByClassName(subContainer)[0].innerHTML =
function (index, text) {
newParagraphText = text.replace("aaa", "bbb");
return newParagraphText;
};
});
Unfortunately, the innerHTML function set the html of the element to be:
function (index, text) { ......
Any help appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…