我正在更改这个现有的 WordPress 主题。 我正在尝试将页脚中的 div 移动到正文。 这是我用appendchild写的,但它似乎不起作用。
function myFunction() {
document.getElementsByClassName("td-post-author-name")[0].setAttribute("id", "block-under-title");
document.getElementsByClassName("td-post-small-box")[0].setAttribute("id", "real-author-name");
var changeName = document.getElementsById("real-author-name");
document.getElementById("block-under-title").appendChild(changeName);
}
window.onload = function() {
myFunction();
};
最佳答案
您有一个拼写错误,没有 getElementsById 方法,将其更改为 getElementById 即可正常工作(第 4 行)
关于javascript - 使用appendchild将一个div添加到另一个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39860313/