Submitting a form by pressing enter without a submit button

前端 未结 20 1535
你的背包
你的背包 2020-11-22 06:46

Well I am trying to submit a form by pressing enter but not displaying a submit button. I don\'t want to get into JavaScript if possible since I want everything to work on a

相关标签:
20条回答
  • 2020-11-22 07:20

    This is my solution, tested in Chrome, Firefox 6 and IE7+:

    .hidden{
        height: 1px;
        width: 1px;
        position: absolute;
        z-index: -100;
    }
    
    0 讨论(0)
  • 2020-11-22 07:21
    input.on('keypress', function(event) {
        if ( event.which === 13 ) {
            form.submit();
            return false;
        }
    });
    
    0 讨论(0)
提交回复
热议问题