我目前正在尝试使用Jquery,在用户按下回车键时将焦点集中在下一个输入类型上。但是,由于某种原因,它无法检测到按键。
这些输入类型位于名为mGrid的CSS类内部。
function addFocusSupport() {
$(".mGrid").find('input').each(function (index, element) {
// Here we get all the TextFields
alert($(this));
$(this).on("keypress",
function (e) {
if (e.KeyCode() === 13) {
// Focus next textfield
alert("Enter Pressed");
var nextElement = $('[index="' + (this.Index + 1) + '"]');
nextElement.focus();
alert(nextElement);
e.preventDefault();
}
// TODO: For last TextField, do nothing
});
});
}
我正在尝试的是: 用户填写第一个输入框,按下回车键后自动选择下一个文本框。可以将其视为按下制表符。
但是在
if (e.KeyCode() === 13) {
之后的事件从未被触发?
e.keyCode
减去 k - sheplukeyCode
不是一个函数。所以使用e.keyCode
。 - prasanth