melvnberd melvnberd - 4 months ago 85x
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


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