<select id="ddlValidationList1">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select id="ddlValidationList2">
</select>
$('#ddlValidationList1').bind('paste cut change keyup', function (e) {
setTimeout(function () {
var ddlValidationList = $('#ddlValidationList2');
ddlValidationList.append(
$('<option></option>').html("EmailAddress")
);
}, 100);
$("#ddlValidationList2 option").each(function () {
alert("hello");
});
});
第一次执行更改功能"ddlValidationList2"
时, foreach
"ddlValidationList1"
功能无效。
答案 0 :(得分:0)
您的setTimeOut函数会导致此更新fiddle:
$('#ddlValidationList1').bind('paste cut change keyup', function (e) {
var ddlValidationList = $('#ddlValidationList2');
ddlValidationList.append(
$('<option></option>').html("Hi")
);
$("#ddlValidationList2 option").each(function () {
alert("hello");
});
});