我对 jQuery 有疑问。不能将 id 传递给包含带有某些事件的 jQuery 的 javascript 函数吗?
例如,load_dll 完美运行。我正在努力update_dll正常工作。
 //Create values for drop down list
var empType = ['Sales Associate', 'New Hire Sales Associate', 'Post-Hire Graduation', 'Senior Supervisor'];
//initialize values
load_ddl(empType, 'empTypeddl');
update_dll('empTypedll', 'empType');
//Populate drop down list function
function load_ddl(arr, id) {
    for (i = 0; i < arr.length; i++) {
        $('<option/>').val(arr[i]).html(arr[i]).appendTo('#' + id);
    }
}
//Update Function
function update_ddl(source_id, target_id) {
    $('#' + source_id).change(function() {
        alert($('#' + source_id + ' option:selected').attr('value'));
    });
}
如果我将其简化为最基本的形式,它仍然可以工作。可以通过id吗?
$('#empTypeddl').change(function() {
     alert($('#empTypeddl option:selected').attr('value'));
});