How to append text inside a div element?
P粉567112391
2023-08-21 11:31:02
<p>I am using AJAX to append data to a <code><div></code> element, which I populate via JavaScript. How do I append new data to <code><div></code> without losing the previous data within it? </p>
Use appendChild:
Use innerHTML:
As @BiAiB reminds me, this method will remove all listeners for existing elements. So if you plan to use this version, please proceed with caution.
Try this: