Textarea提交回车

Textarea提交回车

问题描述:

我有一个表格。当你点击回车按钮。表格正在提交。但是现在我有一个问题。当我在textarea中输入按钮时。然后表单将提交。但在textarea,输入必须是输入。

I have a form. When you hit the enter button. The form is going submit. But now i have a problem. When i hit the enter button in the textarea. Then the form is going submit. But in a textarea, a enter must be a enter.

我该如何解决这个问题?这是我的代码:

How can i fix this? This is my code:

form.keypress(function(e) {
    if (e.which == enter) {
        e.preventDefault();
        $(this).find('[type=submit]').click();
    }
});


试试这个

form.submit(function(e) {
    e.preventDefault();              
    $(this).find('[type=submit]').click();
    $("form").submit();       
})