我有一个包含许多字段表单的联系表单。表单发送一封电子邮件,我想在提交完成后显示一个 div(该 div 的 css 属性显示无,可见隐藏)。
当我使用 onClick 时,如果我单击一个全为空表单的按钮,则会出现 div。 有帮助吗?
我的 JavaScript 函数:
$(document).ready(function () {
$('.ipva_form_calculation').submit(function(event){
$('.ipva_result').show();
return false;
});
});
我的 HTML 表单:
<form action="http://localhost/pedespachante/" method="post" class="avia_ajax_form av-form-labels-hidden avia-builder-el-4 el_after_av_heading avia-builder-el-last ipva_form_calculation av-centered-form av-custom-form-color av-light-form" data-avia-form-id="1" data-avia-redirect="" style="display: none;">...</form>
最佳答案
改用 jQuery submit()
处理程序:https://api.jquery.com/submit/
$('#myForm').submit(function(event) {
//do some form validations
$(this).find('input[type="text"]').each(function() {
if ($(this).val() == '') {
//one or more fields is empty, hence stop here
return false;
}
});
$('.div').show();
});
关于javascript - 如何在提交完成后显示 div 而不是单击按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35686654/