10 examples of 'jquery append row to table tbody' in JavaScript

Every line of 'jquery append row to table tbody' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
260function table_tr_prepend(index){
261 $("tr.slave[data-index=" + index + "]").each(function(){
262 $("#nodes-details").prepend( $(this).prop("outerHTML") );
263 $(this).remove();
264 });
265 var master_content = $("tr.master[data-index=" + index + "]").prop("outerHTML");
266 $("tr.master[data-index=" + index + "]").remove();
267 $("#nodes-details").prepend( master_content );
268};
10export function appendRow(parentTableBody: HTMLTableSectionElement, name: string, options?: { checkbox?: boolean; title?: string; }) {
11 const row = SupClient.html("tr", { parent: parentTableBody});
12 const labelCell = SupClient.html("th", { parent: row });
13
14 let checkbox: HTMLInputElement;
15 if (options != null && options.checkbox) {
16 const container = SupClient.html("div", { parent: labelCell });
17 SupClient.html("div", { parent: container, textContent: name, title: options.title });
18 checkbox = SupClient.html("input", { parent: container, type: "checkbox" }) as HTMLInputElement;
19 } else {
20 labelCell.textContent = name;
21 if (options != null && options.title != null) labelCell.title = options.title;
22 }
23
24 const valueCell = SupClient.html("td", { parent: row });
25
26 return { row, labelCell, valueCell, checkbox };
27}
933_addTbodyOrTheadIfNeed($table) {
934 const isTheadNotExists = !$table.find('thead').length;
935 const isTbodyNotExists = !$table.find('tbody').length;
936 let absentNode;
937
938 if (isTheadNotExists) {
939 absentNode = $('<thead><tr></tr></thead>').get(0);
940 $table.prepend(absentNode);
941 } else if (isTbodyNotExists) {
942 absentNode = $('<tbody><tr></tr></tbody>').get(0);
943 $table.append(absentNode);
944 }
945}
3function buildTable(tableId, jdata) {
4 var elTable = jQuery("#" + tableId);
5 var columns = addColumnHeaders(elTable, jdata);
6 var tbody = elTable.find("tbody");
7 if (tbody.length === 0) { //if there is no tbody element, add one.
8 tbody = jQuery("<tbody></tbody>").appendTo(elTable);
9 }
10 for (var i = 0; i &lt; jdata.length; i++) {
11 var row$ = $('<tr>');
12 for (var colIndex = 0; colIndex &lt; columns.length; colIndex++) {
13 var cellValue = jdata[i][columns[colIndex]];
14 var tdClass = "col r" + i + "c" + colIndex;
15 if (cellValue == null) {
16 cellValue = "";
17 }
18 row$.append($('<td>').html(cellValue).addClass(tdClass));
19 }
20 tbody.append(row$);
21 }
22}</td></tr>
982_appendRow($table, rowDifference) {
983 const newRow = $table.find('tr').last().clone();
984 const brHTMLSting = isIE10 ? '' : '<br />';
985
986 newRow.find('td').html(brHTMLSting);
987
988 for (; rowDifference &lt; 0; rowDifference += 1) {
989 $table.find('tbody').append(newRow.clone()[0]);
990 }
991}
437function appendRowToTable(table, count, cells)
438{
439 var row = table.insertRow(-1);
440 for (var i = 0; i &lt; cells.length; i++)
441 {
442 var cell = row.insertCell(-1);
443 cell.innerHTML = cells[i];
444 }
445
446 if (count)
447 {
448 count.innerHTML = table.getElementsByTagName('tr').length-1;
449 }
450}
223function createTable(tableID, tableContainer, tableData) {
224
225 var table = $('<table>');
226 table.attr('id', tableID);
227
228 table.append($('<caption>').html("Co-authors <a href="\&quot;&quot;">(.CSV File)</a>"));
229
230 var header = $('<thead>');
231
232 var row = $('<tr>');
233
234 var authorTH = $('<th>');
235 authorTH.html("Author");
236 row.append(authorTH);
237
238 row.append($('</th><th>').html("Publications with <br />" + $('#ego_label').text()));
239
240 header.append(row);
241
242 table.append(header);
243
244 $.each(tableData, function(i, item){
245
246 var row = $('</th></tr><tr>');
247
248 row.append($('<td>').html(item.label));
249 row.append($('</td><td>').html(item.number_of_authored_works));
250
251 table.append(row);
252
253 });
254
255 table.prependTo('#' + tableContainer);
256 $('#' + tableContainer + " #loadingData").remove();
257}</td></tr></thead></caption></table>
10public appendRow(...columns) {
11 return this.addRow('appendTo', columns);
12}
7function refreshTableRows(table, data) {
8 var tbody = table.find('tbody');
9 // Clear rows
10 tbody.empty();
11
12 // Append all rows
13 $.each(data, function () {
14 var row = '<tr>';
15
16 for (var key in this) {
17 var val = this[key];
18 row += '<td>' + val + '</td>';
19 }
20
21 row += '<td>-</td></tr>';
22 tbody.append(row);
23 });
24
25}
139function updateTableBody(plugins, tableBody, selector) {
140 var updatedPlugins = [];
141 if (plugins.plugins) {
142 tableBody.find('tr').remove();
143 $.each(plugins.plugins, function() {
144 if (selector(this)) {
145 var plugin = this;
146 if ($.inArray(plugin.key, plugins.updated) &gt; -1) {
147 updatedPlugins.push(plugin);
148 }
149 bindOptionsDropdown($(renderRow(plugin)).appendTo(tableBody));
150 }
151 })
152 } else if (selector(plugins)) {
153 var pos = 0;
154 var oldRow = tableBody.find('tr[data-pluginkey="' + plugins.key + '"]');
155 if (oldRow) {
156 pos = oldRow.parent().children().index(oldRow);
157 oldRow.remove();
158 }
159 var rowContent = renderRow(plugins);
160 var row;
161 if (pos == 0) {
162 row = $(rowContent).prependTo(tableBody);
163 } else if (pos == oldRow.parent().children().length - 1) {
164 row = $(rowContent).appendTo(tableBody);
165 } else {
166 row = $(rowContent).insertAfter(tableBody.find('tr').eq(pos - 1));
167 }
168 bindOptionsDropdown(row);
169 updatedPlugins.push(plugins);
170 }
171 if (tableBody.find('tr').length == 0) {
172 tableBody.append('<tr><td>No extensions</td></tr>');
173 }
174 return updatedPlugins;
175}

Related snippets