Select2 jquery tutorial - reset and empty value (select2 v.3.5 and v.4)

preview_player
Показать описание
in this video i will show you how to reset value select2 jquery. So simple, just add the following script :
$("#address").select2('val', '');
$("#address").html('');

in your javascript ..

that script works on select2 v.3.5.3 and also v.4.0

---
see this video for details.
Рекомендации по теме
Комментарии
Автор

Thanks, for some reason this is not explained in he documentation.
Several blogs uses a completely different approach that doesn't work at all!!!
very very good. Thank You Ambar!

powerengineering
Автор

Thank you.

Work like a charm for reset, but with enable all of your function. I comment the second statement, but not work properly.

MuslimAswaja
Автор

nice approach but is there any way to do it without

rafeemuhammad
Автор

$("#address").select2('val', ''); if im using class $(".select2).select2('val', ''); not working, how to fix this ?

romandahidayat
Автор

Excellent tutorial. 1. Could you please show us how can we add multiple select2 (multi select) div on button click? 2. How can we populate combination of a multi select select2 box's value and show it in a table like the one in Vendhq POS? vendhq.com they have done it beautifully in the product variants creation. (using version 4)

MarioPuzo