简体   繁体   English

从特定行中删除多个表格单元格

[英]Delete multiple table cells from specific row

I want to delete multiple table cells from a row, and I have an array which store the indexes of table cells to be deleted. 我想从一行删除多个表格单元格,我有一个数组存储要删除的表格单元格的索引。 But it deleted only alternative cells. 但它只删除了替代细胞。 I don't have much knowledge in query. 我对查询知之甚少。

Here is My code is. 这是我的代码。

var current_row_id=$(this).parent()[0].id;
var row_elem=document.getElementById(current_row_id);

for(var count=0;count<before_lunchstart_array.length;count++) {
    $('#'+current_row_id+' td').each (function(index) {
        if(index==before_lunchstart_array[count]) {
            $(this).remove();
        }
    });
}

Please help me. 请帮我。

You can try this without any .each() loop but for this you have to use this way: 您可以在没有任何.each()循环的情况下尝试此操作,但为此您必须使用以下方式:

$('yortblID/Class td:eq('+ before_lunchstart_array[count] +')').remove();

I think you are checking for index with count index in before_lunchstart_array array so instead you can do this with .eq() its index start from 0, still it will remove all those tds which index === before_lunchstart_array[count] . 我认为你在before_lunchstart_array数组中检查带有计数索引的索引,所以你可以用.eq()它的索引从0开始,它仍然会删除所有那些index === before_lunchstart_array[count] tds。

So .eq(before_lunchstart_array[count]) is equal to index === before_lunchstart_array[count] . 所以.eq(before_lunchstart_array[count])等于index === before_lunchstart_array[count]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM