JQuery键入不工作的IE 10 [英] JQuery keyup not working IE 10

查看:112
本文介绍了JQuery键入不工作的IE 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码完美适用于Chrome和Firefox。它只会在IE 10上出现混乱。我正在使用JQuery 1.11.1。在控制台中,如果您使用两个密钥,则看起来该密码不会被触发。因此,如果我持有alt+a,它只会在释放它时触发a键盘。在Chrome和Firefox中,它会同时触发。我没有测试IE 10的早期版本。我也无法让JSfiddle正常工作,我不知道如何在JSfiddle中正确使用函数....所以我很抱歉:(。但是这里是(使用alt键)。

  jQuery(document).ready(function(){
var altKey = false;
函数addCheckAlt(){
jQuery(document).bind(keydown,function(e){
if(e.keyCode === 18)$ b $ (b)altKey = true;
});

jQuery(document).bind(keyup,function(e){
if(e.keyCode === 18)
altKey = false;
});
}

函数checkIfAltKey(event){
if(altKey){
event.preventDefault ();
altKey = false;
return false;
}
else {
altKey = false;
return true;
}


code

$ b

HTML

 < input 
type =button
class =btn btn-info helpBtn
onclick =if(checkIfAltKey ))alert('hi');
value =Help
accesskey =6
title =Help(access key 6)/>

使用此代码时,只需使用alt + 6,它将执行单击事件并单击该按钮。如果任何人都可以给我一个关于如何去做这件事的想法,那就太好了! (所有它的作用是,如果alt键被按下,那么它将不会执行警报)

解决方案

添加文档就绪函数中的下一个代码:

  $(#TextBoxName)。keyup(function(){
调试器;
返回true;
});

希望它可以帮助像我这样来到这里的任何人,并解决同样的问题。
这适用于Chrome 47.0.2526.111和IE 11。


This code works perfectly on chrome and firefox. It only messes up on IE 10. I am using JQuery 1.11.1. In the console it appears that the keyup is not fired if you user two keys. So if I hold "alt" + "a" it will only fire the "a" keyup when I release them. In chrome and firefox it will fire both. I did not test on a earlier version of IE only 10. Also I could not get JSfiddle to work properly, I do not know how to use functions correctly in the JSfiddle.... So i am sorry :(. But here is the code. (alt Keys are being used).

jQuery( document ).ready(function(){
 var altKey = false;
    function addCheckAlt(){
        jQuery(document).bind("keydown", function(e){
           if(e.keyCode === 18)
               altKey = true;
        });

        jQuery(document).bind("keyup", function(e){
           if(e.keyCode === 18)
               altKey = false;
        });
    }

   function checkIfAltKey(event){
      if(altKey){
         event.preventDefault();
         altKey = false;
         return false;
      }
      else{
         altKey = false;
         return true;
      }
    }
}

HTML

<input
            type="button"
            class="btn btn-info helpBtn"
            onclick="if(checkIfAltKey(event))alert('hi');"
            value="Help"
            accesskey="6"
            title="Help (access key 6)"/>

when using this code just use alt + 6 and it will do a click event and click the button. If anyone can give me an idea of how to go about this at this point that would be great!! (All it does is if the alt key is being pressed then it will not do the alert)

解决方案

I got it working by adding the next code inside the document ready function:

$("#TextBoxName").keyup(function () {
        debugger;
        return true;
    });

Hope it helps anyone that comes here like I did, with the same problem. This works on Chrome 47.0.2526.111 and IE 11.

这篇关于JQuery键入不工作的IE 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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