Jquery Multiselect:如何知道选择/取消选择哪个值

我有Multiselect下拉列表。 每当有选择或取消选择时,我需要获得该值。 我正在使用更改事件,但努力获取选择/取消选择哪个选项。

试试这个,

$('#selectId').on('change',function(){ console.log($(this).val());// this will give you an array }); 
 // all option var all=[]; $('#multiple').each(function(i, selected){ all[i] = $(selected).text(); }); //selected option var foo = []; $('#multiple :selected').each(function(i, selected){ foo[i] = $(selected).text(); }); // deseleted var de= $.grep(all, function(element) { return $.inArray(element, foo) !== -1; }); 

在foo数组中现在选择的值来了

在de array中获取未选中的值