melvnberd melvnberd - 1 year ago 364
HTML Question

close select2 dropdown via javascript/jquery

Good day, How can I properly close a select2 dropdown via jquery or javascript??

for now Im using

to close it,

but I noticed that It will simply hide the list and the select2 box is still being highlighted enter image description here

I want to lost focus it or something like that just to close it properly and be able to come up with a result like this one enter image description here.

by the way the screen shots are dark because those select2 boxes are under a bootstrap modal that would come up whenever I press enter.

Any advice would really be appreciated! Thanks in advance

Answer Source

this one works for me $("#select2-drop-mask").click();

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download