Here's the fiddle
https://jsfiddle.net/46o8bvcu/1/
$(".chosen").chosen().change(function(e, params){
var id = $(this).val();
alert(id);
});
It returns the value on add option but throws undefined/null/blank when removing option.How can I get the value of the item which was removed?
$(this)
inside the change method refers to the<select></select>
element.The
.change()
method also sends selected and deselected parameter to tell which option was changed. As per the docs here.Something like this should tell you which option was selected and which option was deselected.
Here is a demo https://jsfiddle.net/dhirajbodicherla/46o8bvcu/2/