【发布时间】:2013-02-20 08:08:15
【问题描述】:
我想限制可以按下的键。
$('.txtComments').keydown(function (event) {
var keys = new Array();
keys[0] = "8";
keys[1] = "46";
keys[2] = "37"
keys[3] = "39"
if(!(....)) //Check whether the keyCode is either of 8, 46, 37, or 39.
{
event.preventDefault();
}
});
感谢您的帮助
【问题讨论】:
-
var keys = [8,46,37,39];,那么你可以使用$.inArray和event.which -
尝试使用
$.inArray -
做个好人。停止投票。谢谢。
标签: javascript jquery