如何触发输入按键 [英] How to trigger the enter keypress

查看:152
本文介绍了如何触发输入按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何在输入上触发输入键。也就是说,在响应某些其他事件(不是按键)时,我需要触发值为13的按键。

I need to know how to trigger an enter key on an input. That is, in response to some other event (not a keypress), I need to trigger a keypress of value 13.

(澄清,我不想触发一些当按下回车键时的事件。如果我不知道怎么做,我会发现在SO上已经多次询问和回答。我想要反过来。我正在尝试开发一种需要我模仿的解决方法'输入'按键。)

(Clarification, I do not want to trigger some event when the enter key is pressed. If I didn't know how to do that, I could find that that's been asked and answered several times on SO. I want the reverse. I am trying to develop a workaround that requires I emulate an 'enter' keypress.)

推荐答案

你可以这样做 -

var e = $.Event( "keypress", { which: 13 } );
$('#yourInput').trigger(e);



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