有没有办法将选定的选项放到其他容器中?
与附图相似:
答案 0 :(得分:3)
检查JSFiddle (updated)。当您从#source
中选择一个选项时,它会移至#target
(在此示例中,未移动默认值为零的值):
$(document).on('change', '#source', function() {
$option = $(this).find('option:selected');
if ($option.val()) {
$option.detach();
$option.appendTo('#target');
//select2 adjustments
$('#source').select2('val', '0');
$('#target').select2();
}
});