【问题标题】:How to delete all cell from this table?如何从此表中删除所有单元格?
【发布时间】:2011-07-21 02:24:47
【问题描述】:
<table class="Table">
    <thead class="thead">
        <tr class="tr">
            <th class="th header">Done</th>
            <th class="th header">None</th>
            <th class="th header">None</th>
            <th class="th header">Done</th>
            <th class="th header">None</th>

            <tr>
                <td>info</td>
                <td>info</td>
                <td>info</td>
                <td>info</td>
                <td>info</td>
            </tr>
        </tr>
    </thead>
</table>

我想删除所有“无”单元格和所有“信息”单元格

http://jsfiddle.net/D6e4H/

有什么想法吗?

【问题讨论】:

  • 嗯。所以你想最终得到一张由 Done | 组成的表格。完成了吗?
  • @Furqan 的解决方案删除了​​所有 tdinfo 内容

标签: jquery html-table cell


【解决方案1】:

使用这个

    $(".th:contains('None')") .remove();
    $("td:contains('info')") .remove();

您的 jsFiddle 已更新。

【讨论】:

  • OP 不想删除所有信息 td。多么独特的答案。哇
【解决方案2】:

我想你正在寻找这个

$("th:contains('None')").each(function(index,value) {
    //Grab all the "None" th and their indexes
    $("tr td:nth-child("+$(this).index()+")").remove();
    //remove the td with the same indexes on the next tr
    $(this).remove();
    // now also remove the "None" th
});

这是你的Solution

【讨论】:

    【解决方案3】:

    您正在寻找 :contains() 选择器。

    $('th:contains("None")').remove();
    $('td:contains("info")').remove();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-14
      • 2020-03-11
      • 1970-01-01
      相关资源
      最近更新 更多