Да, вы можете легко получить эти элементы и обновить их свойство name
; см. встроенные комментарии.
deleteThisAssigneeFromSet : function(btn, remove) {
// Get the buttons' parent `tr` (I'd use `closest`, not `parents`)
var parent = $(btn).closest('tr');
if( ! parent.hasClass('pte_row_markup') ) {
// Get the row's siblings
var siblings = parent.siblings('tr');
// Remove the row
parent.remove();
// Update the inputs in the rows, row-by-row
siblings.each(function(i) {
var brackets = "[" + i + "]";
// Uses an "attribute starts with" selector to find the inputs
$(this).find("[name^=assignmentSetGridList]").each(function() {
this.name = this.name.replace(/\[\d+\]/, brackets);
});
});
}
Live Пример:
function deleteThisAssigneeFromSet(btn, remove) {
// Get the buttons' parent `tr` (I'd use `closest`, not `parents`)
var parent = $(btn).closest('tr');
if( ! parent.hasClass('pte_row_markup') ) {
// Get the row's siblings
var siblings = parent.siblings('tr');
// Remove the row
parent.remove();
// Update the inputs in the rows, row-by-row
siblings.each(function(i) {
var brackets = "[" + i + "]";
// Uses an "attribute starts with" selector to find the inputs
$(this).find("[name^=assignmentSetGridList]").each(function() {
this.name = this.name.replace(/\[\d+\]/, brackets);
});
});
}
}
$("input[value=delete]").on("click", function() {
deleteThisAssigneeFromSet(this);
});
<table>
<tr id="IINDEXX">
<td><div id="pte_table_cell_outer">
<div id="pte_table_cell_inner1">
<input type="hidden" name="assignmentSetGridList[0].asIndividuals" value=""/>
<input type="hidden" name="assignmentSetGridList[0].asIds" value=""/>
<input type="hidden" name="assignmentSetGridList[0].asPrincipalIds" value=""/>
<input type="hidden" name="assignmentSetGridList[0].asNames" value=""/>
</div>
</div>
</td>
<td>
<input type="button" value="delete">
</td>
</tr>
<tr id="1">
<td><div id="pte_table_cell_outer">
<div id="pte_table_cell_inner1">
<input type="hidden" name="assignmentSetGridList[1].asIndividuals" value=""/>
<input type="hidden" name="assignmentSetGridList[1].asIds" value=""/>
<input type="hidden" name="assignmentSetGridList[1].asPrincipalIds" value=""/>
<input type="hidden" name="assignmentSetGridList[1].asNames" value=""/>
</div>
</div>
</td>
<td>
<input type="button" value="delete">
</td>
</tr>
<tr id="2">
<td><div id="pte_table_cell_outer">
<div id="pte_table_cell_inner1">
<input type="hidden" name="assignmentSetGridList[2].asIndividuals" value=""/>
<input type="hidden" name="assignmentSetGridList[2].asIds" value=""/>
<input type="hidden" name="assignmentSetGridList[2].asPrincipalIds" value=""/>
<input type="hidden" name="assignmentSetGridList[2].asNames" value=""/>
</div>
</div>
</td>
<td>
<input type="button" value="delete">
</td>
</tr>
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Примечание: похоже, строки имеют индекс как id
s. Если вы хотите исправить их тоже, добавьте это в верхней части обратного вызова siblings.each
:
this.id = i;