gpt4 book ai didi

jquery - 如何让 jquery 清除表格单元格?

转载 作者:行者123 更新时间:2023-12-01 04:25:33 25 4
gpt4 key购买 nike

我的表格如下所示:my table

如果我的第一个单元格中有值,如何让 jquery 删除下拉列表或清除最后一个单元格中的内容?仅当前两个单元格为空时,才会出现下拉菜单。

<table>
<tr>headings here</tr>
<tr>
<td>name</td>
<td>id</td>
<td>other id</td>
<td>status</td>
<td>select location</td>
</tr>
<tr>
<td>name</td>
<td>id</td>
<td>other id</td>
<td>status</td>
<td>select location</td>
</tr>
<tr>
<td>name</td>
<td>id</td>
<td>other id</td>
<td>status</td>
<td>select location</td>
</tr>
</table>

编辑

明白了。我需要一个修剪()。

http://jsfiddle.net/RN5Dn/1/

最佳答案

假设你的表格看起来像

<table>
<tr>
<td>soon it will fade away</td>
<td></td>
</tr>
<tr>
<td>Last Samurai</td>
</tr>
</table>

你可以做到

$(function(){
if(!$("table tr:first").find("td:first").text())
{
$("table tr:last").delay('1000').fadeOut("slow");
}
});

您可以通过选择下拉列表来删除它,然后使用remove将其删除,例如

$("#idOfYourDropDown").remove();

这是工作 fiddle http://jsfiddle.net/3nigma/uF7M5/4/

在 fiddle 中我使用了延迟,以便该值在一段时间内保持可见

jquery :first

jquery :last

编辑

我假设如果没有名称,您想要隐藏/删除选择位置

$(function(){

$("table tr").each(function(){

if(!$("td:first",this).text())
{
$("td:last",this).delay("1000").fadeOut("slow");
}

});

});

这是 fiddle http://jsfiddle.net/3nigma/uF7M5/3/

关于jquery - 如何让 jquery 清除表格单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6753027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com