[英]How to update value of cell of specific row when iterating with each
我正在获取表的第一列的值,并且基于if语句,我需要更新每个特定行的第三列的值。 这是我的工作:
$("#attributes_tbl tr").each(function(){
var value = $(this).find("td input:nth-child(2)").val();
if (value in attribute_enumerations){
description = attribute_enumerations[value]
console.log(description)
$('td:nth-child(3) input').val(description);
}
});
上面的代码片段更新了第三列的所有行。 我需要更新当前行第三列的单元格:
// I need this to update only the specific cell of the current row (from the "each" loop)
$('td:nth-child(3)input')。val(description);
如何在jQuery中指定呢?
要仅影响当前行,请更改:
$('td:nth-child(3) input').val(description);
至:
$(this).find('td:nth-child(3) input').val(description);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.