Asp.net mvc 3 如何使用Jquery在MVC3中按Enter键设置TabIndex

Asp.net mvc 3 如何使用Jquery在MVC3中按Enter键设置TabIndex,asp.net-mvc-3,Asp.net Mvc 3,我的问题是,当我在任何文本框或表单中按enter按钮时,光标会自动转到create按钮并按下它。。。。。我在mvc3工作,所以请告诉我任何解决方案……您可以订阅表单的事件,并在输入时取消它: $(function() { // subscribe to the keypress event of the form $('form').keypress(function(e) { if (e.which == 13) { // if Ente

我的问题是,当我在任何文本框或表单中按enter按钮时,光标会自动转到create按钮并按下它。。。。。我在mvc3工作,所以请告诉我任何解决方案……

您可以订阅表单的事件,并在输入时取消它:

$(function() {
    // subscribe to the keypress event of the form
    $('form').keypress(function(e) {
        if (e.which == 13) {
            // if Enter was pressed cancel the default action and
            // prevent the form from submitting
            return false;
        }
    });
});

@LakhbirChandel,如果这篇文章帮助你解决了你遇到的问题,请点击旁边的勾号来确认。