Hi!
I’ve a select (multiple) and there is some item with different label but same id.
<option value="20">John Moore</option>
<option value="6">Mike Bloom</option>
<option value="20">Dr. J. Moore</option>
I would like to unselect all ID 3 items when user unselect one of them (click on X).
This is my code
/* delete multiple users from select */
$('select[multiple]').on("select2:unselect", function (e) {
// get deleted ID
var user_id = e.params.data.id;
// select obj
var select = $(this);
// get all items
select.find(':selected').each(function(key, el) {
// check if ID is the same
if (el.value == user_id) {
// here the code to unselect current el
}
});
});
how can I unselect an element?
Or there is a way to prevent select items with same value?