/ / añadir una tabla en javascript - javascript, jquery

añada una tabla en javascript - javascript, jquery

Tengo una tabla que muestra datos cada vez que un usuariohace clic en el botón de inicio del evento, pero necesito saber cómo agregar los registros cuando el usuario vuelve a hacer clic en el botón de inicio, el registro anterior se anula

aqui esta mi codigo javascript

function DisplayData(downTime) {
console.log(downTime);
var newContent = "";
$.each(downTime.data, function (i, item) {
newContent += Hesto.Html.StartTR(item.downTime);
newContent += Hesto.Html.CreateTD(item.CategoryName);
newContent += Hesto.Html.CreateTD(item.StartTime);
newContent += Hesto.Html.CreateTD(item.EndTime);
newContent += Hesto.Html.CreateTD(item.Comments);
newContent  = Hesto.Html.EndTR(newContent);
});
$("#DowntimeList").html(newContent);
}

y aquí está mi código html:

<table id="Downtimetable" class="hesto">
<thead>
<tr>
<th>End Of DownTime</th>
<th>Category Name</th>
<th>Start Time</th>
<th>End Time</th>
<th>Comments</th>
</tr>
</thead>
<tbody id="DowntimeList">

</tbody>
<tfoot>
</tfoot>
</table>

Respuestas

2 para la respuesta № 1

Utilizar append() en lugar de sobrescribir la html():

$("#DowntimeList").append(newContent);

1 para la respuesta № 2

Como sugirió en el título de su pregunta, append() eso.

$("#DowntimeList").html(newContent);

Debiera ser

$("#DowntimeList").append(newContent);

0 para la respuesta № 3

Simplemente use,

 document.getElementById("DowntimeList").InnerHtml = document.getElementById("DowntimeList").InnerHtml+newContent