-1
我試圖改變這個jQuery到純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;
};
});
不幸的是,innerHTML的功能設置元素的HTML是:
function (index, text) { ......
任何幫助應用程序reciated。
您正在定義函數,而不是調用它 –