Hello guys.. I have a multiple select and I want to get the clicked option value. No all of them... I have tried many ways but nothing works...
$('selector').val()
it return Array if multiple set to true else a string.
is that deliberate? shouldn't it always return an array?
Isn't Rafsonic looking for the latest clicked option value, i.e. the value of the option that was selected? He did write "No all of them". Currently clickedIndex is returned on the event changed.bs.select, but this isn't the value of the actual select option.
Found solution here - stackoverflow.com
Some modification:
$(".selectpicker").on("changed.bs.select", function(e, clickedIndex, newValue, oldValue) {
var sel = $(this).find('option').eq(clickedIndex).val();
console.log(sel+" "+newValue);
});
Most helpful comment
Found solution here - stackoverflow.com
Some modification: