如何使用 Jquery 在没有 CLASS 的情况下删除 <td>

How Remove <td> without CLASS using Jquery

本文关键字:删除 情况下 td Jquery 何使用 CLASS      更新时间:2023-09-26

任何人都可以给出如何在没有类"响应"的情况下删除<body>内部<td>的想法 jquery ?有关示例,请参阅下面的 HTML 代码。

法典:

<table id="tblFruit" class=" table striped bordered hovered">
       <thead>
            <tr>
                <th>Fruit Name</th>
                <th>Color</th>
                <th>Kilos</th>
                <th>Price</th>
            </tr>
        </thead>
        <tbody id="mybasket">
            <tr>
                <td class="response">Apple</td>
                <td>Apple</td>
                <td class="response">Red</td>
                <td>Red</td>
                <td class="response">5 kilos</td>
                <td>5 kilos</td>
                <td class="response">110.00</td>
                <td>110.00</td>
            </tr>
            <tr></tr>
        </tbody>
    </table>

尝试:

$('td').not('.response').remove();

尝试在此上下文中使用:odd选择器来删除td元素,而无需使用该类,

$('#mybasket > tr > td:odd').remove();

演示

在代码中添加 CSS prperty

您也可以添加内联 CSS

<td class="response" style="display:none">Red</td>
                <td>Red</td>

或制作类

.table td{
display:none;
}
$('td:not(.response)').remove();

谢谢大家的想法,我找到了答案

$('#bodyInfoMilestone tr > td').not('.response').remove();