Submit button outside of the <form> tags

I searched for two hours and I could not find any solutions.

I would like to have two submit buttons, one inside the <form> and one outside the <form>.

<form id="example" name="example" action="post"> Input <input type="text" name="text" /> <input type="submit" name="submit" value="submit" /> </form> <div class="button">Submit</div> 

Js / jquery

 $(".button").click( function() { alert("Button clicked"); }); 

How can I submit a form with a class (.button) outside the form?

JS Fiddle here: http://jsfiddle.net/ZQLXb/

+6
source share
5 answers

Use the submit() function to start submitting the form:

 $(".button").click( function() { $('#example').submit(); }); 

You can also use the trigger() function:

 $(".button").click( function() { $('#example').trigger('submit'); }); 

Although they do the same.

+12
source

use submit() to submit the form

 $(".button").click( function() { $('#example').submit(); }); 
+3
source

You can trigger the submit event in the form:

 $('#example').trigger('submit') 
+1
source
 $(".button").click( function() { $('#example').submit(); }); 
+1
source
 $(".button").bind("click",function() { $('#example').submit(); }); 
+1
source

All Articles