如何使用其类名在同一td元素中找到checkbox元素 [英] how can I find the checkbox element in the same td element using its class name
本文介绍了如何使用其类名在同一td元素中找到checkbox元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在表中有两列,一个带有复选框,另一个是Input元素.我试图从javascript中找到checkbox元素,并从javascript中进行检查.这是我的代码
I have two column in a table one with checkbox and another is Input element. I am trying to find the checkbox element from javascript and to get checked from javascript . Here is my code
var chbox = $(this).closest('tr').find('.nhrs a').empty();
// simillarly I have to find checkbox element and to set its checked property =true
<table>
<tbody>
<tr>
<td>
<input asp-for="@Model.attendanceLogList[i].IsProtected" type="hidden" />
<input type="checkbox" value="true" disabled asp-for="@Model.attendanceLogList[i].IsNormalAttendance" data-tag="NormalHrs" />
<input type="hidden" value="false" asp-for="@Model.attendanceLogList[i].IsNormalAttendance" />
<input asp-for="@Model.attendanceLogList[i].IsClockingEnabled" type="hidden" />
</td>
<td class="nhrs">
<a href="#" class="disabled" data-pk="NormalHrs">@Model.attendanceLogList[i].NormalHrs</a>
<input asp-for="@Model.attendanceLogList[i].NormalHrs" type="hidden" class="bros" />
</td>
</tr>
</tbody>
</table>
推荐答案
您的意思是
$(this).closest("tr").find("[data-tag=NormalHrs]").prop("checked",true);
这篇关于如何使用其类名在同一td元素中找到checkbox元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文