0
I create a table
dynamically from the result of a bank query.
But I would like to have a control to eliminate the <tbody>
of the same.
I can do it using the command :
var body = $("#tbSemana").find('tbody').remove();
$("#tbSemana").append(document.createElement('tbody'));
But the table
has not id, how can I make that same exclusion without the id?
following table created:
for (var i = 0; i < ciclos.length; i++) {
var atual = ciclos[i];
var html = "<table class=\"table\"><thead>" +
"<tr>" +
"<th>Pts Sem. 1</th>" +
"<th>Qualificação Sem. 1</th>" +
"<th>Pts Sem. 2</th>" +
"<th>Qualificação Sem. 2</th>" +
"<th>Pts Sem. 3</th>" +
"<th>Qualificação Sem. 3</th>" +
"<th>Pts Sem. 4</th>" +
"<th>Qualificação Sem. 4</th>" +
"</tr>" +
"</thead<tbody><tr>";
if (semana[0] != null) {
if (true) {
//html += "<td>" + atual.id + " - " + atual.nome + "</td>";
html += "<td style=\"text-align: center; \">" + atual.totPst1 + "</td>";
html += "<td style=\"text-align: center; \">" + atual.grad1 + "</td>";
a += ciclos[i].totPst1;
}
else {
//html += "<td>" + atual.id + " - " + atual.nome + "</td>";
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
}
else {
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
if (semana[1] != null) {
if (true) {
html += "<td style=\"text-align: center; \">" + atual.totPst2 + "</td>";
html += "<td style=\"text-align: center; \">" + atual.grad2 + "</td>";
b += ciclos[i].totPst2;
}
else {
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
}
else {
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
if (semana[2] != null) {
if (true) {
html += "<td style=\"text-align: center; \">" + atual.totPst3 + "</td>";
html += "<td style=\"text-align: center; \">" + atual.grad3 + "</td>";
c += ciclos[i].totPst3;
}
else {
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
}
else {
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
if (semana[3] != null) {
if (true) {
html += "<td style=\"text-align: center; \">" + atual.totPst4 + "</td>";
html += "<td style=\"text-align: center; \">" + atual.grad4 + "</td>";
d += ciclos[i].totPst4;
}
else {
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
}
else {
html += "<td style=\"text-align: center; \">0</td>";
html += "<td style=\"text-align: center; \">-</td>";
}
html += "</tr>";
//$("#tbgrad").find('tbody').append(html);
html += "</tbody></table>";
}
Instead of
$("#tbSemana")
use$("table.table")
– Sorack
@Sorack it deletes another table I have on the page. I just put as example the code, pq use in it. Now to delete a table made via Javascript do not know.
– Igor Carreiro