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:



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();
);





Have you tried $('#approve_do-table tbody tr').remove() ? That should remove ALL row in tbody... (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



$('#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.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

How do I collapse sections of code in Visual Studio Code for Windows?