聆听所有表单提交事件 [英] Listening to all form submit events

查看:66
本文介绍了聆听所有表单提交事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery的on('submit', ...)正确地选择了本机表单提交,即,当按下提交"按钮时,但是它不适用于JS表单提交,至少在FF& IE上是如此

jQuery's on('submit', ...) correctly picks up native form submits i.e. when the submit button is pressed, however it doesn't play well with JS form submits, at least on FF&IE

考虑到这一点,如何适当地"添加提交侦听器?通过更改HTMLFormElement.prototype.submit的行为来修改DOM原型不适用于IE7

With that in mind, how would one go about adding submit listeners "properly"? Modifying DOM prototype by changing the behaviour of HTMLFormElement.prototype.submit doesn't work on IE7

摆弄

推荐答案

使用jQuery .submit()提交表单将解决此问题.

Using the jQuery .submit() to submit your form will take care of the problem.

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

jsFiddle演示

如果您真的坚持使用本机DOM .submit(),当然不会有太大帮助.

Of course it won't help much if you really insist on using the native DOM .submit().

这篇关于聆听所有表单提交事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆