1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>使用Button提交表单</title> 6 </head> 7 <body> 8 <form id="form"> 9 <input type="text" name="username" /> 10 <br> 11 <input type="button" value="提交" onclick="submit()" /> 12 </form> 13 </body> 14 <script type="text/javascript"> 15 function submit() { 16 // 获取form 17 var form = document.getElementById("form"); 18 form.method = "post"; 19 // 提交form 20 form.submit(); 21 } 22 </script> 23 </html>