最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - keycode 13 and keycode 10 not working - Stack Overflow

programmeradmin2浏览0评论

Event keypress 13 and 10 not working on iPhone safari, android firefox but working with android default browser.

I have a jsp page which has a form which that takes a number as input and changes values of other div elements in the same page by dividing those numbers by this input.

I am using keypress function of jQuery and testing with keycode 10 and 13 for this. It's working on all desktop browsers but the GO button doesn't fire on safari and firefox on smart phones. Please let me know how to go about this?

Here is the partial code I have used:

$('.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');
        ...
        ..

    }
}

The ".number" is the class name used in the input form which has type="text". So, basically I am not using submit at all.

Event keypress 13 and 10 not working on iPhone safari, android firefox but working with android default browser.

I have a jsp page which has a form which that takes a number as input and changes values of other div elements in the same page by dividing those numbers by this input.

I am using keypress function of jQuery and testing with keycode 10 and 13 for this. It's working on all desktop browsers but the GO button doesn't fire on safari and firefox on smart phones. Please let me know how to go about this?

Here is the partial code I have used:

$('.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');
        ...
        ..

    }
}

The ".number" is the class name used in the input form which has type="text". So, basically I am not using submit at all.

Share Improve this question edited Mar 28, 2016 at 7:06 Shashank Agrawal 25.8k11 gold badges96 silver badges125 bronze badges asked Aug 11, 2011 at 15:47 SrinivasSrinivas 1454 silver badges9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Try using keyup and keydown. keypress event is not really ideal.

发布评论

评论列表(0)

  1. 暂无评论