Clear dropdown using jQuery Select2

前端 未结 15 2101
情深已故
情深已故 2020-11-28 11:35

I\'m trying to programmatically clear a drop down using the fantastic Select2 library. The drop down is dynamically filled with a remote ajax call using the Select2 qu

15条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 12:14

    You can use this or refer further this https://select2.org/programmatic-control/add-select-clear-items

    $('#mySelect2').val(null).trigger('change');
    

提交回复
热议问题