5

事件keypress13 和 10 不适用于 iPhone safari、android firefox,但适用于 android 默认浏览器。

我有一个 jsp 页面,它的表单将数字作​​为输入,并通过将这些数字除以该输入来更改同一页面中其他 div 元素的值。

我正在使用keypressjQuery 的功能并为此使用 keycode 10 和 13 进行测试。它适用于所有桌面浏览器,但 GO 按钮不会在智能手机上的 safari 和 firefox 上触发。请让我知道该怎么做?

这是我使用的部分代码:

$('.number').keypress(function(e) {
    if(e.keyCode == 10 || e.keyCode == 13 ) {

        $('#1').html((textreplace/input).toFixed(0)+'g');
        $('#2').html((textreplace2/input).toFixed(0)+'%');
        $('#3').html((textreplace3/input).toFixed(0)+'g');
        ...
        ..

    }
}

“.number”是输入表单中使用的类名,其 type="text"。所以,基本上我根本不使用提交。

4

1 回答 1

7

尝试使用keyupkeydownkeypress事件并不理想。

于 2011-08-11T16:01:45.810 回答