Skip to content Skip to sidebar Skip to footer
Reading Time: < 1 minute

When you’re working with jQuery select2 you might be seen it’s clear option not working event use the allowClear parameter. This post will explain about the issue and how to fix that.

Once you click on the clear button you can see the following javascript errors messsages from the browser console panel.

jQuery select2 dropdown allowClear not working1. Check if you included new version of select2 plugin. Select2 Official website.

2. Use the allowClear parameter as true state.

$('.mydropdownbox').select2({ 
   allowClear: true,
   placeholder: 'Please select',
});

3. Also you can use the below code as separate code.

$('.mydropdownbox').val(null).trigger('change');

 

Note: The allowClear option should be used in combination ‘ + ‘with the placeholder option.