I have a number of select boxes that have been set to accept multiple values. Is there anyway that I can use jQuery to get the last selected value? I\'ve tried using the f
Here is the code to get the latest selected option from multiple select list using Jquery :
var selected;
$(document).ready(function() {
$('#SELECT_ID').on('click', function() {
var latestSelected;
if (selected) {
var currentOptionsValue = $(this).val();
latestSelected = currentOptionsValue.filter(function(element) {
return selected.indexOf(element) < 0;
});
}
selected = $(this).val();
console.log( "latest selected option : " + latestSelected);
});
});