在jquery中获取tab按事件 [英] Get tab press event in jquery

查看:80
本文介绍了在jquery中获取tab按事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jsgrid ,我需要通过键盘按下或上/下箭头按键事件(当jsgrid处于可编辑模式时)在jquery中。



我尝试过:



< script>

$(输入).keydown(函数(e){

调试器;

if (e.which === 9)

alert(Hurray !!!);

});

< / script> ;



以上代码片段无效。我认为这是因为jquery / css使网格行可编辑但上面的代码片段无法找到输入。



标签按的实例是http://jsfiddle.net/QfCpC/1/

解决方案

(输入).keydown(函数(e){

调试器;

if(e.which === 9)

alert( Hurray !!!);

});

< / script>



以上代码片段不起作用。我认为这是因为jquery / css使网格行可编辑但上面的代码片段无法找到输入。



标签按下的实例是http://jsfiddle.net/QfCpC/1/


 < script  < span class =code-attribute>   type   =  text / javascript >  
document.onkeyup = PresTab;

函数PresTab(e)
{
var keycode =(window。事件)? event .keyCode:e.keyCode;
if (keycode == 9
alert(' 按Tab键);
}

< / script >


I am using jsgrid and i need tab press or up/down arrow key press event from keyboard (when jsgrid is in editable mode) in jquery.

What I have tried:

<script>
$("input").keydown(function (e) {
debugger;
if (e.which === 9)
alert("Hurray!!!");
});
</script>

above code snippet is not working.I think this happens due to jquery/css make grid row editable but above code snippet is unable to find input.

live example of tab press is http://jsfiddle.net/QfCpC/1/

解决方案

("input").keydown(function (e) {
debugger;
if (e.which === 9)
alert("Hurray!!!");
});
</script>

above code snippet is not working.I think this happens due to jquery/css make grid row editable but above code snippet is unable to find input.

live example of tab press is http://jsfiddle.net/QfCpC/1/


<script type="text/javascript">
       document.onkeyup = PresTab;
 
       function PresTab(e)
       {
           var keycode = (window.event) ? event.keyCode : e.keyCode;
           if (keycode == 9)
           alert('tab key pressed');
       }
 
   </script>


这篇关于在jquery中获取tab按事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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