2
votes

I wonder how can I remove the selected item in SELECT2. Because by default it adds an item selected in the first case. But I need you any be selected by default.

For when it loads the page, I try to click on the first item. It does not return the change event because the item is already selected.

aria-selected = "true"

$ (".select"). select2 ({
placeholder: "Select an Item"
});
1

1 Answers

1
votes

One solution would be to attach to the select2:close event and capture the selected value that way.

$('.select').on('select2:close', function(){
    var selectedValue = $(this).val();
});

This will allow you to capture the value of the already selected first item without relying on the change event.