我想将一个参数传递给我的函数。该参数将是一个表示CSS类名称的变量。基于哪个复选框被选中,我将设置变量的值(例如,如果选择了CheckBox1,变量的值将是类名'.list1')。jQuery:将参数传递给函数
下拉列表有大量的选项,我想根据他们的'类'选择一个选项的子集,并使用这些选项来填充另一个列表(fl_listEmpty)。
这里是我的代码,据我已经得到了:
function FillDropDownList(parameter) {
$('.fl_list1 [**put class name parameter here**]).each(function (index) {
$(".fl_listEmpty").append($('<option> </option>').val(index).html($(this).text()));
})
}
的可能重复[jQuery的:把一个变量和选择器$(“选择”)里面?(HTTP:/ /stackoverflow.com/questions/5642923/jquery-put-a-variable-and-a-selector-inside-the-selector)...请在提问之前使用搜索。 [这被问了很多次](http://stackoverflow.com/search?q=jquery+variable+selector) –