使用jQuery在文本框中按Enter键 [英] Press the enter key in a text box with jQuery

查看:66
本文介绍了使用jQuery在文本框中按Enter键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery模仿< input>中的输入按钮?

我想模拟在文本框中按下的输入按钮,并从jQuery触发此命令。请释放帮助

解决方案

在jquery中使用 keypress 事件



 


#textboxid )。keypress( function (event){
if (event.which == 13 ){
// code这里
// 13代表回车键
}
});





或者你可以使用



 


#textboxid)。live(' keypress' function (event){
if (event.which == 13 ){
// 此处代码
}
});





来自此处


How can I mimic pressing the enter button from within a <input>, using jQuery?
I want to simulate the enter button being pressed inside the textbox, and trigger this from jQuery.Please Help

解决方案

use keypress event in jquery


( "#textboxid" ).keypress(function( event ) { if ( event.which == 13 ) { //code here //13 represents Enter key } });



or you can use


("#textboxid").live('keypress',function(event){ if(event.which == 13){ //code here } });



More info from here


这篇关于使用jQuery在文本框中按Enter键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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