Can I open a dropdownlist using jQuery

Jon Tackabury picture Jon Tackabury · Dec 11, 2008 · Viewed 152.3k times · Source

For this dropdownlist in HTML:

<select id="countries">
<option value="1">Country</option>
</select>

I would like to open the list (the same as left-clicking on it). Is this possible using JavaScript (or more specifically jQuery)?

Answer

CommentLuv picture CommentLuv · Dec 21, 2010

I was trying to find the same thing and got disappointed. I ended up changing the attribute size for the select box so it appears to open

$('#countries').attr('size',6);

and then when you're finished

$('#countries').attr('size',1);