0
我有一个简单的HTML这样的:为什么jQuery e.which无法检测输入密钥?
Get alert with inserting a + sign: <input type="text" class="data" />
我要警告用户,每当他/她按+关键。但我的jQuery代码不起作用:
$(document).ready(function(){
$(".data").bind('keydown',function(e){
if(e.which == 107){
alert('Plus sign entered');
});
});
});
我该怎么办?
(这是my jsFiddle)
尝试使用的keydown的KEYUP代替。也检查这个http://stackoverflow.com/questions/302122/jquery-event-keypress-which-key-was-pressed – emaillenin 2012-01-15 07:21:31