I have the following <select>
:
<select id="multiselect" multiple="multiple">
<option value="pedra">Pedra</option>
<option value="papel">Papel</option>
<option value="tesoura">Tesoura</option>
</select>
With the Jquery code below, I can get the value of the last% selected_with%:
<script type="text/javascript">
$(document).ready(function() {
$('#multiselect').multiselect();
$(document).on('change','#multiselect', function(){
console.log (( $('option', this).filter(':selected:last').val() ))
});
});
</script>
But what I really wanted was to get the value of <option>
clicked (I know <option>
will not work in this case), regardless of whether it is being selected or deselected.
I searched a lot, but the most I found, was how to find the value of the last one selected.
The plugin used is Bootstrap-multiselect