作为用于客户端的表的拖放选项的一部分,我试图在客户端更改其顺序时重命名每行中的控件。脚本按预期用于每个控件 用于尝试查找this fiddle所示的下拉列表。我不确定问题是什么,但下面是UpdateNames()脚本,它处理重命名控件和重新着色行。
function UpdateNames() {
$('.sorted_table tr').each(function (i, row) {
// Reference all the stuff you need first
var $row = $(row),
$remove = $row.find('input[name*="chkRemove_"]'),
$list = $row.find('input[name*="dlList_"]'),
$section = $row.find('input[name*="txtSection_"]'),
$name = $row.find('input[name*="txtName_"]'),
$value = $row.find('input[name*="txtValue_"]'),
$comments = $row.find('input[name*="txtComments_"]');
//Now to actually rename them
$remove.attr('name', "chkRemove_" + (i - 1));
$list.attr('name', "dlList_" + (i - 1));
$section.attr('name', "txtSection_" + (i - 1));
$name.attr('name', "txtName_" + (i - 1));
$value.attr('name', "txtValue_" + (i - 1));
$comments.attr('name', "txtComments_" + (i - 1));
var rowCSS = 'tableinfobody tableinfoGray';
if ((i % 2) === 0) {
rowCSS = 'tableinfobody';
}
$row.attr("class", rowCSS);
});
我应该注意行着色也有效。