提交后通过 Jquery 重置我的表单的问题

Issue getting my form to reset via Jquery after submission

我目前遇到了一个问题,我查看了 Whosebug、w3c 和其他各种搜索选项。 我已经尝试了 javascript、jquery 甚至 php 的每个选项,但我似乎无法在提交后重置此表单。下面附上代码,请帮忙!

表单功能:

$(function()
{
    function after_form_submitted(data) 
    {
        if(data.result == 'success')
        {   
            $('form#car-inquiry').siblings('#form-welcome').hide();
            $('form#car-inquiry').hide();
            $('#success_message').show();
            $('#error_message').hide();
            $('#car-inquiry')[0].reset();

灯箱关闭和打开功能:

if (!container.is(e.target) // if the target of the click isn't the container...
    && container.has(e.target).length === 0) // ... nor a descendant of the container
{
    document.getElementById('overlay').style.display = "none";
    document.getElementById('#car-inquiry').reset();
    container.fadeOut();
}
});

/* close form button*/
function closeForm() {
   document.getElementById("contact-car-form").style.display = "none";
   document.getElementById('#car-inquiry').reset();
   document.getElementById('overlay').style.display = "none";
}

如果我能提供任何其他有用的东西,请告诉我。谢谢!

只需为您的表单分配一些 ID,然后像这样触发重置事件

 $('#form_id').trigger("reset");

或者像这样刷新您的页面

 location.reload();

它将重置您的表格。