我是 Jquery 的新手,我正在尝试附加一个选择选项。这有效,当我在选择中选择新添加的选项时。我在警报中变得不确定。
var selects = $(this).closest('div').find('.accSelectandlookup') ;
//Check if the accid is already present in the selectoptions and if not then add
if (!selects.find('option[value="' + accid + '"]').length) {
alert(accid); // This throws up the correct value
selects.append('<option value="' + accid + '">Attach to Existing : ' + accname + '</option>');
}
我究竟做错了什么 ?
提前致谢
selects.change(function(){
alert('selected value is ' + selects.filter(":selected").val()); // This throws undefined
})