在页面提交之前直接执行javascript代码 [英] Execute javascript code straight before page submit
本文介绍了在页面提交之前直接执行javascript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一些类似的问题,但没有完全相同。
There are a few similar questions to this but none quite the same.
我想知道是否有一个事件可用于执行某些JS之前页面正在提交(即已发布)。
I want to know if there is an event that can be used to execute some JS before a page is submitting (i.e. POSTed).
推荐答案
如果您正在使用表单,则可以使用 onsubmit event。
If you are working with the form, you can use onsubmit event.
使用jQuery你可以用
Using jQuery you can do that with
$('#myform').submit(function() {
// your code here
});
这篇关于在页面提交之前直接执行javascript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文