【发布时间】:2011-06-02 12:11:26
【问题描述】:
我有一个使用 jQuery 将 RETURN 键替换为 TAB 的网络应用程序,这样当我用户按下返回时,表单不会被提交,而是光标移动到下一个文本字段。
这适用于所有浏览器,但只有 1/2 适用于 iPad。在 iPad 上,下一个字段被突出显示,但键盘被隐藏。如何保持键盘可见或以某种方式强制它?
这是我的代码(感谢http://thinksimply.com/blog/jquery-enter-tab):
function checkForEnter (event) {
if (event.keyCode == 13) {
currentBoxNumber = textboxes.index(this);
if (textboxes[currentBoxNumber + 1] != null) {
nextBox = textboxes[currentBoxNumber + 1]
nextBox.focus();
nextBox.select();
event.preventDefault();
return false;
}
}
}
Drupal.behaviors.formFields = function(context) {
$('input[type="text"]').focus(function() { $(this).removeClass("idleField").addClass("focusField"); });
$('input[type="text"]').blur(function() { $(this).removeClass("focusField").addClass("idleField"); });
// replaces the enter/return key function with tab
textboxes = $("input.form-text");
if ($.browser.mozilla) {
$(textboxes).keypress (checkForEnter);
} else {
$(textboxes).keydown (checkForEnter);
}
};
【问题讨论】: