gpt4 book ai didi

javascript - 如何遍历中的元素

转载 作者:行者123 更新时间:2023-11-30 10:27:55 32 4
gpt4 key购买 nike

HTML:

<tr id="head-58">
<td style="width:150px;">
<input type="button" name="delete" class="delete_person" value="58" />name<button type="button" style="margin: 1px 35px 5px;" name="delete" value="58" class="delete_icon button_style">Delete</button>
</td>
<td>
<input type="checkbox" name="first_aid" id="id_first_aid" />FirstAid
</td>
<td>
<input type="checkbox" name="sick_bay" id="id_sick_bay" /Sick bay
</td>
<td>
<input type="checkbox" name="ambulance" id="id_ambulance" />Ambulance
</td>

</tr>

点击 delete_person 类时,我想显示带有 delete_icon 类的隐藏按钮。由于类 delete_icon 可以有多个,我需要显示隐藏按钮形式的点击元素。我尝试使用 $this.closest ('tr').find(".delete_icon").toggle(); 不起作用。

最佳答案

使用:

$this.parents('tr').find(".delete_icon").toggle();

关于javascript - 如何遍历<tr>中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18704232/

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