Jquery submit form [duplicate]

2019-01-10 22:28发布

This question already has an answer here:

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

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

7条回答
ら.Afraid
2楼-- · 2019-01-10 22:44

Try this :

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

or

document.form1.submit();
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-01-10 22:47

You can try like:

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

Or even you can try like

$(".nextbutton").click(function() { 
    $('#form1').submit();
});
查看更多
做个烂人
4楼-- · 2019-01-10 22:51

Try this lets say your form id is formID

$(".nextbutton").click(function() { $("form#formID").submit(); });
查看更多
Ridiculous、
5楼-- · 2019-01-10 22:55

Since a jQuery object 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 submit by doing :

$(".nextbutton").click(function() { 
  $("#formID")[0].submit();
});
查看更多
The star\"
6楼-- · 2019-01-10 22:56

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:

document.forms[0].submit();
查看更多
放荡不羁爱自由
7楼-- · 2019-01-10 23:07

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

$(".nextbutton").click(function() { 
   document.forms["form1"].submit();
});
查看更多
登录 后发表回答