I am using Jquery Select2 plugin for Multi Select Dropdown with Check box by referring the below code pen link.
Ref:Please find this [codepen link][1]
https://codepen.io/faur/pen/vWVPGE
When I search for Options List as 'opt' and choosing the element from the Elements. After the selection, my searched term 'opt' still showing in the input box. I want to clear the searched text after selecting the element. How Can I do that?
I had the exact same problem with Select2 Version 4.1.0-beta.1 and I searched for a long time, then I found this solution which use the generic selector for the select and at the time of selection it clears the value of the search__field. For me it worked perfectly. Hope it will work for you too:
$("select").on('select2:select', function (e) {
$('.select2-search__field').val('');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.