如何在 Firefox 中按下向下箭头时显示 html select 的所有选项

How to show up all options of html select when press down arrow in Firefox

如果您将焦点放在 select 元素上,然后按下按钮,所有选项都会显示在 chrome 中,就像您单击 select 元素一样,但是在firefox,按下按钮时选项不会显示,有没有办法在按下 down/up 按钮时显示它?

触发点击不起作用,这是显而易见的答案。也许你可以扩大向下箭头的大小,然后在向上箭头上将其设置回 1?

<select id="select">
<option>Value 1</option>
<option>Value 2</option>
<option>Value 3</option>
<option>Value 4</option>
</select>

jQuery(function ($) {
    $(document).keyup(function (e) {
        // down arrow (open)
        if (e.keyCode == 40) {
            $('#select').attr('size', $('#select option').length);
        }
        // up arrow (close)
        if (e.keyCode == 38) {
            $('#select').attr('size', 1);
        }   
    });
});

Fiddle: https://jsfiddle.net/kxghjj3s/