前端使用 JQuery 的 form.submit() 方法提交表单无效,没有任何反应。

提交按钮代码:

<button type="button" class="btn btn-success" id="submit" name="submit">提交</button>

JQuery代码:

$("#submit").on('click',function(){
    $('#recordForm').submit();
}

错误原因是 button 的 id 和 name 是 submit 与 submit() 方法重名,只要把 id 和 name 的名字改一下就好了。

修改后的代码:

<button type="button" class="btn btn-success" id="btn-submit">提交</button>

$("#btn-submit").on('click',function(){
    $('#recordForm').submit();
}
(adsbygoogle = window.adsbygoogle || []).push({});