There is another way to fix it. You can hide an element before disconnecting it from the DOM, but in a different event handling. Something like that:
// HTML structure: <div id="aaa"> <a id="bbb"> Text </a> </div> var bbb = document.getElementById('bbb'); var container = document.getElementById('aaa'); bbb.attachEvent("onclick", function() { bbb.style.display = "none"; window.setTimeout(function() { container.removeChild(bbb); bbb.style.display = ""; // Some time later window.setTimeout(function() { container.appendChild(bbb); }, 2000); }, 1); });
bbb.style.visibility = "hidden" also works.
source share