How to append data to div using JavaScript?

前端 未结 11 1947
忘了有多久
忘了有多久 2020-11-22 09:39

I\'m using AJAX to append data to div element, where I fill the div from JavaScript, how can I append new data to the div without losing the previous data found in div?

11条回答
  •  萌比男神i
    2020-11-22 10:28

    java script

    document.getElementById("divID").html("this text will be added to div");
    

    jquery

    $("#divID").html("this text will be added to div");
    

    Use .html() without any arguments to see that you have entered. You can use the browser console to quickly test these functions before using them in your code.

提交回复
热议问题