【问题标题】:Why when I press GO in iPad, does not focus next input?为什么当我在 iPad 中按 GO 时,不关注下一个输入?
【发布时间】:2013-02-11 18:58:12
【问题描述】:

假设我在display: none; 中有很多 div,而只有第一个在visible

在视图中,您可以按 ENTER 或 GO(在 iPad 中)浏览每个视图。所以想前进的时候,把当前的div改成none,下一个就改成visible。但是现在我还想将焦点设置在具有focusable 类的输入元素中。但它并没有设置焦点。

这是我的代码:

var setFocus = function () {
    $("#question-container2").find("#question:visible").find('.focusable')[0].focus();
    $("#question-container2").find("#question:visible").find('.focusable')[0].setSelectionRange(0, 0);
};

var nextPage = function () {
    if ($currentPage < $totalPages) {
        $currentPage++;
        $("#question-container2").find("#question:visible").hide().next().show();
    }
};

$(".input-area").keypress(function (e) {
    if (e.keyCode == 13) {
        // Do something
        nextPage();
        setFocus();
        return false;
    }
});

【问题讨论】:

    标签: javascript jquery html css ipad


    【解决方案1】:

    在你的元素中指定一个标签索引。这是一个浏览器可访问性属性,当您完成当前字段时,它将告诉浏览器下一步导航到哪里。

    见:http://reference.sitepoint.com/html/a/tabindex

    【讨论】:

      猜你喜欢
      • 2020-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-14
      • 1970-01-01
      • 1970-01-01
      • 2020-02-16
      相关资源
      最近更新 更多