jQuery jquery提交表单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3752134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:02:05  来源:igfitidea点击:

Jquery submit form

jqueryformssubmit

提问by user342391

How can I submit a specific form using the follow code (example the id of my form is #form1).

如何使用以下代码提交特定表单(例如我的表单 ID 为 #form1)。

$(".nextbutton").click(function() { submit; });

回答by Pramendra Gupta

Try this lets say your form id is formID

试试这个让我们说你的表单 ID 是 formID

$(".nextbutton").click(function() { $("form#formID").submit(); });

回答by Gautam3164

You can try like:

你可以尝试像:

   $("#myformid").submit(function(){
        //perform anythng
   });

Or even you can try like

或者甚至你可以尝试像

$(".nextbutton").click(function() { 
    $('#form1').submit();
});

回答by challet

Since a jQueryobject inherits from an array, and this array contains the selected DOM elements. Saying you're using an id and so the element should be unique within the DOM, you could perform a direct call to submitby doing :

由于一个jQuery对象继承自一个数组,而这个数组包含了选定的 DOM 元素。假设您使用的是 id,因此该元素在 DOM 中应该是唯一的,您可以通过执行以下操作直接调用提交

$(".nextbutton").click(function() { 
  $("#formID")[0].submit();
});

回答by Alex B.

You don't really need to do it all in jQuery to do that smoothly. Do it like this:

你真的不需要在 jQuery 中完成这一切才能顺利完成。像这样做:

$(".nextbutton").click(function() { 
   document.forms["form1"].submit();
});

回答by Vova Popov

If you have only 1 form in you page, use this. You do not need to know id or name of the form. I just used this code - working:

如果您的页面中只有 1 个表单,请使用此表单。您不需要知道表单的 id 或名称。我刚刚使用了这段代码 - 工作:

document.forms[0].submit();

回答by Rob Bach

Use the following jquery to submit a selectbox with out a submit button. Use "change" instead of click as shown above.

使用以下 jquery 提交一个没有提交按钮的选择框。如上所示,使用“更改”而不是单击。

$("selectbox").change(function() { 
   document.forms["form"].submit();
});

Cheers!

干杯!

回答by Ram Ch. Bachkheti

Try this :

尝试这个 :

$('#form1').submit();

or

或者

document.form1.submit();