2016-10-04 114 views
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(); 

}; 
+0

你有一個錯字,沒有法getElementsById,將其更改爲getElementById,它會正常工作(第4行) – sidanmor

回答

2

你有一個錯字,沒有法getElementsById,將其更改爲是的getElementById,它會正常工作(4號線)

+0

謝謝,這是問題!!!!!!!! –

相關問題