I have the following multi select:
<select multiple="multiple" id="select_empresas" name="my-select[]">
<option value='elem_1'>elem 1</option>
<option value='elem_2'>elem 2</option>
<option value='elem_3'>elem 3</option>
<option value='elem_4'>elem 4</option>
</select>
and the next JQuery:
$('#select_empresas').on('change',function(e) {
var unselected = $(this).find('option:last:not(:selected)').val();
alert(unselected);
});
What I want to do is show me the value
of the last option deselected, for example if elem 2
is selected and then the user gives click
on it and will go to deselect, at that moment is when I want get the value of said option
, which would be elem_2
.
But the problem is that it does not show me the value I want.
If someone can help me I would appreciate it very much