使用 jQuery 触发按键事件的最终方法 [英] Definitive way to trigger keypress events with jQuery

查看:21
本文介绍了使用 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?

推荐答案

如果你想触发 keypress 或 keydown 事件,那么你所要做的就是:

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屋!

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