用jQuery触发按键事件的最终方法 [英] Definitive way to trigger keypress events with jQuery
本文介绍了用jQuery触发按键事件的最终方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读了关于这些问题的所有答案,没有一个解决方案似乎不起作用。
I've read all the answers on to this questions and none of the solutions seem to work.
此外,我得到的氛围,触发按键与特殊字符根本不起作用。有人可以验证谁做了这个吗?
Also, I am getting the vibe that triggering keypress with special characters does not work at all. Can someone verify who has done this?
推荐答案
如果您想触发按键或键盘事件,那么您只需要执行以下操作:
If you want to trigger the keypress or keydown event then all you have to do is:
var e = jQuery.Event("keydown");
e.which = 50; // # Some key code value
$("input").trigger(e);
这篇关于用jQuery触发按键事件的最终方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文