Javascript 提交表单仅在firefox浏览器中不起作用
我从Bootstrap modal提交了一个表单,我只对Firefox有一个问题,它的代码非常简单Javascript 提交表单仅在firefox浏览器中不起作用,javascript,jquery,firefox,Javascript,Jquery,Firefox,我从Bootstrap modal提交了一个表单,我只对Firefox有一个问题,它的代码非常简单 $('#confirmBtn').click(function(e){ e.preventDefault(); $('#s-form').submit(); }); 从模态调用它 <div class="modal" tabindex="-1" role="dialog" id="sipChannel"> <div class="modal-dialog
$('#confirmBtn').click(function(e){
e.preventDefault();
$('#s-form').submit();
});
从模态调用它
<div class="modal" tabindex="-1" role="dialog" id="sipChannel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><strong>Updating SIP Channel</strong></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Please confirm we are updating <%= @customer.company_name %> SIP channels from x to y,
this will affect your billing and will take affect within the next few minutes.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" type="submit" id="confirmBtn">Confirm</button>
</div>
</div>
</div>
</div>
更新SIP频道
&时代;
请确认我们正在将SIP频道从x更新到y,
这将影响您的账单,并将在未来几分钟内生效
取消
证实
形式
%>
频道:
编辑
如果我把
console.log(“…”
放在我的jquery函数中,我可以通过单击按钮看到我正在调用函数,但是Firefox忽略了submit
,那么我如何解决这个问题呢?为什么不把按钮放在表单中,而不使用jquery呢?
或者向其添加form=“s-form”
如果不是,它应该是type=button,这样您就不需要单击事件的默认值
否则,如果需要确认,请使用
$('#s-form').on("submit",function(e) {
if (!confirm("Are you sure")) e.preventDefault();
});
能否将表单部分添加到代码中?不建议使用内联事件处理程序
$('#s-form').on("submit",function(e) {
if (!confirm("Are you sure")) e.preventDefault();
});