var old_element = document.getElementById("btn"); var new_element = old_element.cloneNode(true); old_element.parentNode.replaceChild(new_element, old_element);