I am confused: whats going on with the following code
var ProductFeatures = [];
for (var i = 1; i < 3; i++) {
ProductFeatures.push({
Guid: $('#FeatureListTable tr').eq(i).attr('id'),
Value: $('#FeatureListTable td:nth-child(5)').eq(i-1).val(),
Remark: $('#FeatureListTable td:nth-child(6) input').eq(i-1).val()
});
}
When I comment out the “Value:” row, I get a different result in the Remark field than when there are no comments
// Value: $('#FeatureListTable td:nth-child(5)').eq(i-1).val(),
Why does this happen?
Thanks in advance, Julian
Not sure why the
Remarkvalue would change when you comment out theValueline, but this line:…would only return
nullorundefined(I don’t remember which one), because it is trying to get thevalueof a<td>instead of a form input.This sort of data structure is much better built using jQuery’s
.map()method.