Reading the documentation for document.write() , we find this:
Writes a line of text to the document stream opened by document.open() . [...]
Writing to a document that is already loaded without calling document.open() will automatically make the document.open call
... and the documentation for document.open() says:
The document.open () method opens a document for writing. [...]
If the document exists in the target, this method clears it.
Using document.write() to enter raw HTML is perhaps the most annoying tool for creating dynamic documents. You are using jQuery using your DOM manipulation tools.
source share