Prevent form submission on Enter key press

前端 未结 19 1935
失恋的感觉
失恋的感觉 2020-11-22 04:18

I have a form with two text boxes, one select drop down and one radio button. When the enter key is pressed, I want

相关标签:
19条回答
  • 2020-11-22 05:18

    Detect Enter key pressed on whole document:

    $(document).keypress(function (e) {
        if (e.which == 13) {
            alert('enter key is pressed');
        }
    });
    

    http://jsfiddle.net/umerqureshi/dcjsa08n/3/

    0 讨论(0)
提交回复
热议问题