How to open Chosen via JavaScript?

Tzvi picture Tzvi · Jul 19, 2012 · Viewed 13k times · Source

I need to open the Chosen dropdown via JavaScript so users do not have to click on the select to show it, how can this be done?

Answer

techfoobar picture techfoobar · Jul 19, 2012

You can open a chosen select box via JS by doing:

$('#<id-of-your-select>_chzn').trigger('mousedown');

where <id-of-your-select> is the id of your <select> element.

For ex: if your <select> element is like <select id="foo" ...>, then the code above will become:

$('#foo_chzn').trigger('mousedown');