jQuery-防止默认,然后继续默认 [英] jQuery - prevent default, then continue default
问题描述
我有一个表单,提交后,我需要做一些额外的处理,然后才能提交表单.我可以阻止默认的表单提交行为,然后进行其他处理(基本上是在调用Google Maps API并向表单添加一些隐藏字段)-然后我需要提交表单.
I have a form that, when submitted, I need to do some additional processing before it should submit the form. I can prevent default form submission behavior, then do my additional processing (it's basically calling Google Maps API and adding a few hidden fields to the form) -- and then I need the form to submit.
有没有一种方法可以防止默认设置",然后在以后继续继续默认设置"呢?
Is there a way to "prevent default", then some point later "continue default?"
推荐答案
当您将.submit()
事件绑定到表单,并且在返回(true)之前执行了您想做的事情时,这些事情发生在实际提交.
When you bind the .submit()
event to the form, and you do the things you want to do before returning (true), these things happen prior to the actual submission.
例如:
$('form').submit(function(){
alert('I do something before the actual submission');
return true;
});
jquery.com上的另一个示例: http://api.jquery.com/submit/#entry-examples
Another example on jquery.com: http://api.jquery.com/submit/#entry-examples
这篇关于jQuery-防止默认,然后继续默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!