0
我正在對此存在的wordpress主題進行更改。 我正在嘗試在頁腳中將div移至正文。 這是我用appendchild寫的,但它似乎不工作。使用appendchild將div添加到另一個div
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行) – sidanmor