【发布时间】:2021-07-17 03:37:43
【问题描述】:
我有一个表格,其中包含 2 个日期类型输入、一个跨度和 2 个用于编辑和保存的可点击图标。我的目标是在编辑图标上的 td 的“onClick”中启用输入类型日期。但我不知道如何访问 td 中的元素来更改 disabled 属性。在编辑时,禁用属性应该是 False,并且在更改后如果他单击保存图标,禁用属性应该回到 True。如果我可以在默认情况下禁用保存图标(不可点击),如果没有先点击编辑按钮,并且在保存后它会恢复为禁用状态,那么对我来说是一个加号。
这是我的 HTML 代码:
<table class="table table-striped" id="pageNbr">
<thead>
<tr class="header">
<th>Begin Date</th>
<th>End Date</th>
<th>School Year</th>
<th></th>
</tr>
</thead>
<tbody id="myTable">
<tr>
<td><input type="date" class="BeginDate " onchange="fill()" disabled> </td>
<td><input type="date" class="EndDate" id="enddate" disabled> </td>
<td> <span id="Syear"> 2021-2022</span></td>
<td style="box-shadow: none !important; background-color: white !important;">
<a href="#"><i class="far fa-save Icon-save"></i></a>
<a href="#">
<i class="far fa-edit Icon-edit"></i></a>
</td>
</tr>
</tbody>
</table>
到目前为止,我的 jQuery 是:
$('.Icon-edit').click(function() {
var currentTD = $(this).parents('tr').find('td');
$.each(currentTD, function() {
$(this).prop();
});
});
$('.Icon-save').click(function() {
var currentTD = $(this).parents('tr').find('td');
$.each(currentTD, function() {
$(this).prop();
});
});
【问题讨论】:
标签: javascript html jquery html-table disabled-input