选择框展开时未触发jQuery keypress/keyup/etc事件 [英] jQuery keypress/keyup/etc events not fired when select box is expanded

查看:93
本文介绍了选择框展开时未触发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.

这篇关于选择框展开时未触发jQuery keypress/keyup/etc事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆