gpt4 book ai didi

Jquery:仅获取提交表单的输入

转载 作者:行者123 更新时间:2023-12-01 07:45:35 24 4
gpt4 key购买 nike

我在一个页面中有多个表单。我只需要获取提交表单的输入子项。

这是我的代码(当然它不起作用)。

    $('form.modal-form').on('submit',function(e) {
e.preventDefault();
var form_errors = 0;
$(this).children('input.required-field').each(function(index)
{
[....]
});
});

非常感谢

最佳答案

您需要使用$.fn.find而不是$.fn.children ,它只获取直接子级:

$(this).find('input.required-field').each(function(index) {
// ...
});

关于Jquery:仅获取提交表单的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38744961/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com