I have a in my website, and I have a script in jquery that has this function:
$(\"#multi\").on
To get the last selected by the user, you can do this
var map = $("#multi").on("change",function(){
var comp = $("#multi option:selected").map(function() {
return this.value;
}).get(),
set1 = map.filter(function(i) {
return comp.indexOf(i) < 0;
}),
set2 = comp.filter(function(i) {
return map.indexOf(i) < 0;
}),
last = (set1.length ? set1 : set2)[0];
map = comp;
// "last" contains the last one selected /unselected
}).find('option:selected').map(function() {return this.value}).get();
FIDDLE