Sushant Bajracharya
Sushant Bajracharya

Reputation: 63

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 ?

Upvotes: 0

Views: 669

Answers (1)

Runcorn
Runcorn

Reputation: 5224

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.

Upvotes: 2

Related Questions