Jquery 表行父项()不工作
我这里有嵌套表和删除动画。Jquery 表行父项()不工作,jquery,Jquery,我这里有嵌套表和删除动画。class=“record”删除操作非常完美,但是class=“nested”不起作用。当我删除记录时,class=“record”我还想删除class=“nested”嵌套记录。但是为什么它不起作用呢 这是我的输出。当我删除计数器000007时,嵌套表也应该有delete动画,但只有000007的记录 HTML <table id="tfhover"> <thead> <tr> <th></th> <
class=“record”
删除操作非常完美,但是class=“nested”
不起作用。当我删除记录时,class=“record”
我还想删除class=“nested”
嵌套记录。但是为什么它不起作用呢
这是我的输出。当我删除计数器000007时,嵌套表也应该有delete动画,但只有000007的记录
HTML
<table id="tfhover">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr class="record">
<td></td>
</tr>
// Nested Table
<tr>
<td>
<table id="loginTable">
<thead>
<tr class="nested">
<th></th>
</tr>
</thead>
<tbody>
<tr class="nested">
<td></td>
</tr>
</tbody></table> // Nested table Close
</td></tr> // Nested table tr td Close
</tbody></table> // Main table Close
//嵌套表
//嵌套表关闭
//嵌套表tr td Close
//主表关闭
完全删除脚本
<script>
$(function() {
$(".delbutton").click(function(){
//Save the link in a variable called element
var element = $(this);
//Find the id of the link that was clicked
var del_id = element.attr("name");
//Built a url to send
var info = 'name=' + del_id;
if(confirm("Sure you want to delete this update? There is NO undo!"))
{
$.ajax({
type: "GET",
url: "delete.php",
data: info,
success: function(){
}
});
$(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
.animate({ opacity: "hide" }, "slow")
}
return false;
});
});
</script>
$(函数(){
$(“.delbutton”)。单击(函数(){
//将链接保存在名为element的变量中
var元素=$(此);
//查找已单击的链接的id
var del_id=element.attr(“名称”);
//构建了一个要发送的url
var info='name='+del_id;
如果(确认(“确实要删除此更新?没有撤消!”)
{
$.ajax({
键入:“获取”,
url:“delete.php”,
数据:信息,
成功:函数(){
}
});
$(this.parents(“.record”).animate({backgroundColor:{fbc7c7},“fast”)
.animate({opacity:“hide”},“slow”)
}
返回false;
});
});
您没有有效的HTML,因为您有一个
元素直接嵌套在另一个
元素中。(注意带有
的行)
也许你想要这个:
<table id="tfhover">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr class="record">
<td></td>
</tr>
<tr>
<td>
<table id="loginTable">
<thead>
<tr class="nested">
<th></th>
</tr>
</thead>
<tbody>
<tr class="nested">
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
您没有有效的HTML:
。您不应该将一个
直接放在另一个
中。你应该先修复它。@JohnS为什么无效?但在我的代码中它是有效的。最后一个问题是主表行的结尾不能像那样嵌套。如果您想让外部tbody有两行,您应该将第二行
移动到//嵌套表@JohnS好的,对不起。您的权利。请添加到问题中,以显示由$(this)
表示的元素的位置。您的建议有效。谢谢但是我的问题呢?我已经用我最好的猜测更新了我的答案(不知道更多)。@John s你好,先生?你在吗?@user3097736-有用吗?我现在在这里几分钟。这很有帮助,只是想更改代码中的某些内容。我想在嵌套表的TR中制作动画。//嵌套表。我试图更改类名,但不起作用。请帮帮我
<table id="tfhover">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr class="record">
<td>
<table id="loginTable">
<thead>
<tr class="nested">
<th></th>
</tr>
</thead>
<tbody>
<tr class="nested">
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
$(this).closest(".record").animate({
backgroundColor: "#fbc7c7"
}, "fast").animate({
opacity: "hide"
}, "slow");
$(this).closest(".record").next().find(".nested").animate({
backgroundColor: "#fbc7c7"
}, "fast").animate({
opacity: "hide"
}, "slow");