如何提交之前做些事情? [英] How to do something before on submit?
本文介绍了如何提交之前做些事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表单,它有一个提交表单的按钮。在提交之前我需要做些事情。我尝试了在按钮上执行
i have a form which has a button that submits the form. I need to do something before submits happen. I tried doing onClick on that button but it happens after the submit.
我无法共享代码,但通常我应该怎么做如何在jQuery或JS中处理这个问题?
I can't share the code but, generally, what should I do in jQuery or JS to handle this?
推荐答案
<form id="myform">
...
</form>
您可以使用以下jQuery代码在提交表单之前执行某些操作:
You can use the following jQuery code to do something before the form is submitted:
$('#myform').submit(function() {
// DO STUFF...
return true; // return false to cancel form action
});
这篇关于如何提交之前做些事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文