gpt4 book ai didi

jquery - 在 jQuery 中删除父

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

我有以下表结构:

<table class="table table-bordered">
<tr>
<th width="70%">File</th>
<th width="15%">Size</th>
<th width="15%">Delete</th>
</tr>
<tr>
<td>Mon fichier</td>
<td>3 kB</td>
<td><a href="#" class="deleteFile" id="007"> Delete </a></td>
</tr>
</table>

JS:

$('.deleteFile').click(function(){
if (confirm("Delete ?")){
$imagefile = $(this).attr('id');
$.ajax({
...

如何删除/隐藏 <tr>包含我的链接?

最佳答案

TR 是您情况下 anchor 标记祖先,因此请使用.closest()以获得想要的结果。

尝试,

$(this).closest('tr').remove();

你的代码,

$('.deleteFile').click(function(){
if (confirm("Delete ?")){
$(this).closest('tr').remove(); //removing the TR
$imagefile = $(this).attr('id');
$.ajax({
...

关于jquery - 在 jQuery 中删除父 <td>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20709557/

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