我有一个可编辑的表:
$('.table-salva').click(function() {
$(this).parents('tr').attr("contenteditable", "false");
});
$('.table-modifica').click(function() {
$(this).parents('tr').attr("contenteditable", "true");
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<div class="table-editable">
<table id="table" class="tabella text-center">
<thead>
<tr class="hide">
<th>ID</th>
<th>Data</th>
<th>Entrata</th>
<th>Uscita</th>
</tr>
</thead>
<tbody>
<tr>
<td>#</td>
<td>AAAA-MM-GG</td>
<td>00:00</td>
<td>00:00</td>
<td id="bottoni">
<span class="table-salva"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Salva</button></span>
<span class="table-modifica"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Modifica</button></span>
</td>
</tr>
</tbody>
</table>
</div>
在表格中,当用户点击"Modifica“按钮时,你可以编辑字段并按"Salva”保存(是的,按钮是禁用的,但之后它们不会被禁用)。我希望用户不能编辑"ID“字段,如何修改父项(‘tr’)以排除td的第一个?
编辑:我有另一个问题。当用户点击"Modifica“时,他也可以编辑按钮的值。如何阻止按钮的值编辑?
发布于 2018-11-11 05:04:22
我还怀疑您也不希望这些按钮可编辑
您可以使用以下命令将适用的<td>设置为目标:
$(this).parent().siblings().not(':first').attr(...https://stackoverflow.com/questions/53243277
复制相似问题