解决方法
在github上的线程中有一个描述。引用(
https://github.com/ivaynberg/select2/issues/195#issuecomment-13489140通过
MortadaAK),它允许您选择ctrl a上的所有内容
$(document).on("keypress",".select2-input",function(event){ if (event.ctrlKey || event.MetaKey) { var id =$(this).parents("div[class*='select2-container']").attr("id").replace("s2id_",""); var element =$("#"+id); if (event.which == 97){ var selected = []; element.find("option").each(function(i,e){ selected[selected.length]=$(e).attr("value"); }); element.select2("val",selected); } else if (event.which == 100){ element.select2("val",""); } } });