Keypress活动在Chrome中无效 [英] Keypress event not working in Chrome

查看:90
本文介绍了Keypress活动在Chrome中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我试过按键事件,输入按钮在IE和firefox中工作正常

但不在chrome中

Hello everyone i tried the keypress event for enter button that is working fine in IE and firefox
but not in chrome

$('.div').bind('keypress', function (e) {
       if (e.keyCode == 13) {
           alert("Enter prssed");
       }
   });



请帮我解决


Please help me in this

推荐答案

' 。div')。bind(' keypress' function (e){
if (e .keyCode == 13 ){
alert( 输入prssed);
}
});
('.div').bind('keypress', function (e) { if (e.keyCode == 13) { alert("Enter prssed"); } });



请帮帮我


Please help me in this


Hello Ravi,



我在 JSFiddle.Net 设置了一个演示[ ^ ],甚至可以在chrome中使用。由于您尚未共享HTML标记,因此我可以自由使用自己的标记,这可能与您的标记不同。请随意摆弄它。



在您的情况下,如果要绑定到特定按钮,则可能需要将选择器更改为基于id的选择器('#'+ CONTROL_ID)。 br $>


问候,
Hello Ravi,

I have setup a demo at JSFiddle.Net[^], which even works in chrome. Since you have not shared the HTML markup, I have taken liberty to use my own markup, which may be different than your's. Please feel free to fiddle with it.

In your case if you want to bind to a particular button then you may want to change your selector to an id based selector ('#' + CONTROL_ID).

Regards,


Hello Ravi,

I have setup a demo at JSFiddle.Net[^], which even works in chrome. Since you have not shared the HTML markup, I have taken liberty to use my own markup, which may be different than your's. Please feel free to fiddle with it. 

In your case if you want to bind to a particular button then you may want to change your selector to an id based selector ('#' + CONTROL_ID).

Regards,
  Permalink    Posted 25-Jun-13 7:42am


这篇关于Keypress活动在Chrome中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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