What you're doing is not optimal. The best solution would be this:
When the form gets successfully submitted, just hide() the FORM element, and show() the message (which is initially hidden). And then, later, just show() the FORM element and hide() the message.
Mmmm, how much more beneficial is this? I mean - why is this not optimal - how much is show/hide better?
@abolotnov Writing your FORM element into a string will destroy all event handlers that are bound on that form or any of its ancestor elements (like form fields). All other changes that were done programmatically on the form element or any ancestor will be lost too. HTML rewriting is a horrible idea.
@imeVidas what is your thought on using .clone(true, true) which will also clone data and event handlers, and will also do that for all children of the cloned element(as per jQuery API doc)?
concerning the use case the OP was facing, or as in you example, in case might you want to clone a FORM element.