选择框展开时未触发jQuery keypress/keyup/etc事件

问题描述:

在此处查看我的代码示例: http://pastebin.com/D1ZctG11

Check out my code sample here: http://pastebin.com/D1ZctG11

要点是:如果展开了选择框(通过键盘或鼠标),则jquery的按键事件似乎不会触发-至少在Mac Chrome中不会触发.

The gist is: If you have a select box expanded (either via the keyboard or mouse), jquery's key events do not seem to fire - at least not in Mac Chrome.

有没有解决方法?

我的最终目标是在使用optgroup元素时在选择框展开时选择用户输入的内容.

My end goal is to select what the user has typed while the select box is expanded when using the optgroup element.

jsfiddle链接: http://jsfiddle.net/XacfX/

jsfiddle link: http://jsfiddle.net/XacfX/

谢谢
穆斯塔法(Mustafa)

Thanks
Mustafa

我认为您必须使用jQuery的change():

I think you have to use jQuery's change():

http://jsfiddle.net/vvBqE/11/

除非我误解了您,否则您可以看到用户以这种方式选择了哪个选项.您也可以在示例中使用按键事件,但是如果用户仅使用鼠标选择一个选项,则不会触发回调函数.

Unless I misunderstood you, you can see which option the user has selected this way. You can also use the key events in my example but the callback function won't be triggered if the user selects an option by using mouse only.