简体   繁体   English

如何删除 <td> 没有使用jQuery的CLASS

[英]How Remove <td> without CLASS using Jquery

Can anyone give an idea on how to remove <td> inside <body> without CLASS "response" usig Jquery ? 任何人都可以提出一个想法,如何在没有CLASS“响应” usig Jquery的情况下删除<body>内部的<body> <td>吗? Please see may HTML Code below for sample . 请参阅下面的HTML代码示例。

CODE: 码:

<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>

Try to use :odd selector at this context to remove the td elements with out using the class, 尝试在此上下文中使用:odd选择器,以不使用类的方式删除td元素,

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

DEMO 演示

尝试:

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

add css prperty in code 在代码中添加css prperty

you can add inline css also 您也可以添加内联CSS

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

or make class 或上课

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

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

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

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

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