Javascript 使用appendchild将一个div添加到另一个div

Javascript 使用appendchild将一个div添加到另一个div,javascript,append,appendchild,Javascript,Append,Appendchild,我正在改变现有的wordpress主题。 我正在尝试将页脚中的一个div移动到body。 这是我用appendchild写的,但它似乎不起作用 function myFunction() { document.getElementsByClassName("td-post-author-name")[0].setAttribute("id", "block-under-title"); document.getElementsByClassName("td-post-small-

我正在改变现有的wordpress主题。 我正在尝试将页脚中的一个div移动到body。 这是我用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行)

您有一个输入错误,没有方法getElementsById,将其更改为getElementById,它将正常工作(第4行)

您有一个输入错误,没有方法getElementsById,将其更改为getElementById,它将正常工作(第4行)您有一个输入错误,没有方法getElementsById,将其更改为getElementById,它将正常工作(第4行)谢谢,这就是问题所在!!!!!谢谢,这就是问题所在!!!!!!!!