此代码打印大约 15 行数据,每行附近都有这个选择框。我需要为每一行捕获用户选择的值,以将其发送到下一个函数。我收到此错误:未捕获的类型错误:对象 # 没有方法“val”。有没有更好的方法来实现这一目标?
count = 1;
$.each(data, function(index, element) {
$('<div class="hd_field">Payment Format: <select name="Payment_Format" id="Payment' + count + '" class="Payment_Format"><option value="CTX" selected="selected">Company to Company</option><option value="PPD">Company to Person</option></select><div id ="Selected_Format' + count + '"></div></div>').appendTo(newDiv3);
$('select#Payment' + count).change(function() {
alert(this.val());
PaymentFormat = $(this).val();
element.PmtRec.PmtFormat = PaymentFormat;
$('#Selected_Format' + count).text(PaymentFormat);
});
console.log(data);
count = count + 1;
});