我有多选下拉菜单。每当有选择或取消选择时,我都需要获取该值。
我正在使用更改事件,但很难确定选择/取消选择了哪个选项。
//all options
var all=[];
$('#multiple').each(function(i, selected){
all[i] = $(selected).text();
});
//selected options
var foo = [];
$('#multiple :selected').each(function(i, selected){
foo[i] = $(selected).text();
});
// unselected options
var de= $.grep(all, function(element) {
return $.inArray(element, foo) !== -1;
});
In the foo
数组是选定的值
In the de
数组是未选择的值
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)