Trying to append a button to both the top and bottom of the body tag, however it's only performing whichever one of the two is last. Am I missing something obvious here?
var msg_node = document.createElement("a");
msg_node.setAttribute("onclick", "collapseAll()");
msg_node.setAttribute("href", "javascript:void(0)");
msg_node.setAttribute("class", "kc_button");
var msg_textnode = document.createTextNode('COLLAPSE ALL');
msg_node.appendChild(msg_textnode);
document.getElementsByTagName('body')[0].appendChild(msg_node); // supposed to make button
document.body.insertBefore(msg_node, document.body.children[0]); // makes only this button
createElementtwice.var msg_node_2 = msg_node;or do i have to repeat the entire code over again?var msg_node_2 = msg_node.cloneNode(true);as Matansh's answer points out.