gpt4 book ai didi

jQuery 选择2 : Put selected options to other container

转载 作者:行者123 更新时间:2023-12-01 08:02:39 25 4
gpt4 key购买 nike

有没有办法将选定的选项放入其他容器?

如附图所示:

enter image description here

最佳答案

检查这个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();
}
});

关于jQuery 选择2 : Put selected options to other container,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18825513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com