5
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 <option>
selected:
<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 (know that on('click', func..)
will not work in this case), regardless of whether it is being selected or deselected.
I did a lot of research, but the most I could find was how to find the value of the last selected.
The plugin used is the Bootstrap-multiselect
I’m not sure if this is what you want, but look at this Jsfiddle with an example of what seems to me to be what you seek.
– Zuul
@Zull, the concept is exactly this. I read the plugin documentation, and adapted. Thank you for helping.
– Eric Vieira