jQuery clean text in TR Table
jQuery clean text in TR Table
How to clear all text that appears in a TR table ?
Here is my table:

Below is my script - I put text in the TR
$('#approve_do-table').delegate('tr', 'click', function()
var html;
if ($('#approve_do-table #do-show tr').length === 1)
html = '<tr id="no-data"><th style="text-align:center;" class="table-conf even" colspan="5">No data found</th></tr>';
$('#approve_do-table > tbody').html(html);
var $this = this;
var id = $(this).attr('id'),
latest_no = $(this).children('td:eq(0)').text(),
part_name = $(this).children('td:eq(1)').text(),
req = $(this).children('td:eq(2)').text(),
price = $(this).children('td:eq(3)').text(),
amount = $(this).children('td:eq(4)').text(),
part_id = $(this).data('part_id');
rows_selected.push(this);
ids_selected.push(id);
arrPartIds.push(part_id);
loc = id.replace('part_do', '');
loctab = $.inArray(id, ids_selected);
locP = loctab+1;
$('#part_doDest-table tr:eq('+locP+') td:eq(0)').html(latest_no);
$('#part_doDest-table tr:eq('+locP+') td:eq(1)').html(part_name+'<i class="fa fa-times eks" aria-hidden="true" id="'+id+'"></i>');
$('#part_doDest-table tr:eq('+locP+') td:eq(2)').attr('contenteditable': false, 'id': 'edit'+loc, 'oninput': 'inputFunc("'+loc+'")','onblur':'removeTooltips("'+loc+'")', 'placeholder': '0').html(req);
$('#part_doDest-table tr:eq('+locP+') td:eq(3)').attr('id', 'price'+loc).html(price);
$('#part_doDest-table tr:eq('+locP+') td:eq(4)').attr('id','amount'+loc).html(amount);
$(this).remove();
sumSubtotal2();
);
And here is my script to clear the array, but the text on the element isn't cleared.
$('.cancel_btn').click(function(event)
alert(1);
ids_selected = ;
rows_selected = ;
$('#part_doDest-table').closest('tr').remove();
$(this).closest('tr').remove();
);
$('#approve_do-table tbody tr').remove()
tbody
yes, but there is removing TR element , i want set empty the TR element sir like html(""); but here also not working , also i was tried text("");
– Roby Firnando
Sep 5 '18 at 5:02
1 Answer
1
I want set empty the TR element sir, like html("");
To "empty" some table rows... Without removing them, you have to empty the cells (which are td).
td
Try this:
$('#approve_do-table tbody td').empty()
still not working sir :(
– Roby Firnando
Sep 5 '18 at 6:18
i tried and that script removing TR element
– Roby Firnando
Sep 5 '18 at 6:21
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you tried
$('#approve_do-table tbody tr').remove()? That should remove ALL row intbody... (I'm not sure that is what you mean, but that's all I understand for now.)– Louys Patrice Bessette
Sep 5 '18 at 4:48