alert("Selected value is: "+$(".leaderMultiSelctdropdown").select2("val"));
或者,如果您使用常规选择框作为基础,您也应该能够使用普通的jquery调用:
alert("Selected value is: "+$(".leaderMultiSelctdropdown").val());
两者都返回所选键的数组 .
73
我知道它已经很晚了,但我想你可以这样试试
$("#multipledpdwn").on("select2:select select2:unselect", function (e) {
//this returns all the selected item
var items= $(this).val();
//Gets the last selected item
var lastSelectedItem = e.params.data.id;
})
8 回答
或者,如果您使用常规选择框作为基础,您也应该能够使用普通的jquery调用:
两者都返回所选键的数组 .
我知道它已经很晚了,但我想你可以这样试试
希望它可能在将来帮助一些人 .
返回对象结构中的选定数据:
就像是:
返回选定的val:
就像是:
试试这样,
简单地说
试试这个:
这将从多值选择框中获取选定值:$(“#id option:selected”) . val()
拜托这个简单的example . 您可以在 select2 multi 中获取值 .