聆听所有表单提交事件 [英] Listening to all form submit events
问题描述
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();
如果您真的坚持使用本机DOM .submit()
,当然不会有太大帮助.
Of course it won't help much if you really insist on using the native DOM .submit()
.
这篇关于聆听所有表单提交事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!