如何防止我的$('form')。submit(function(event))被应用于某些表单

时间:2022-03-04 20:31:09

I have a dynamic page with many different forms and use $('form').submit(function(event) to process the form after it is submitted. I need to prevent the script from being applied to upload type forms because they are handled differently. Is there a way to do this? Thanks!

我有一个包含许多不同表单的动态页面并使用$('form')。submit(function(event)在提交表单后处理表单。我需要阻止脚本应用于上传类型表单,因为它们被处理不一样。有办法做到这一点吗?谢谢!

My Code:

$(document).ready(function() {
    $('form').submit(function(event) {

    //processes stuff

    });
});

1 个解决方案

#1


2  

Give your forms different classes with CSS and then you can target the ones you want specifically when you call the submit function.

使用CSS为表单提供不同的类,然后在调用提交函数时可以专门定位所需的类。

Example:

$(document).ready(function() {
    $('.process').submit(function(event) {

    //processes stuff

    });
});

<form class='process'>
</form>

#1


2  

Give your forms different classes with CSS and then you can target the ones you want specifically when you call the submit function.

使用CSS为表单提供不同的类,然后在调用提交函数时可以专门定位所需的类。

Example:

$(document).ready(function() {
    $('.process').submit(function(event) {

    //processes stuff

    });
});

<form class='process'>
</form>