First highlight the important parts:
- (first click) Accepts the
source element and places it inside the target element; - (second click) Empties the
target element and adds a new child ( p.dummy ) to it, effectively removing source from the DOM; - Empties the
target element and tries to re-add source , which is no longer present in the DOM.
At first, this does not work in any browser, since the source element has already been removed from the DOM. The “magic” here is the JavaScript Garbage Collector . Browsers see that sourceEl is still in range (inside the setTimeout closure) and does not delete the associated DOM element inside the jQuery sourceEl object.
The problem here is not the JScript implementation (Microsft Javascript implementation) of the Garbage Collector, but the way JScript handles the DOM parsing when setting the innerHTML element.
Other browsers simply separate all of the childNode (which will be compiled by the GC when there are no more active links) and childNode html string passed in the DOM elements, adding them to the DOM. Jscript, on the other hand, will also remove the detached childNode s' innerHTML / childNode s. For an illustration look a violin .
The element, in fact, still exists in IE and is added to the DOM:

It no longer has a childNode .
To prevent this behavior, .clone() element (as mentioned in the question) or .detach() before calling .html() on your parent element if you intend to reuse the element instead of overwriting it.
Here the script using .detach() before overwriting the item works fine in all browsers.
source share