Sushant Bajracharya Sushant Bajracharya - 5 months ago 13
jQuery Question

How to get the value of crossed item from the multiple select in select2?

I am using the select2 plugin version 3.5.2. I am using the multiple select. Now suppose I selected a value from the dropdown list and then removed it again by clicking on the cross icon, how can I know its value ?

Answer

Select2 provides different events that you can use to catch selection, removal or other events. For your case you can use select2-removed event,

 $("#multipleSelectExample").on("select2-removed", function(e) {
     alert(e.val);
    })

Here is an working JSFiddle.

Also, I suggest you to use latest version of Select2 if possible as they have added tons of new features that you can work on with.