当我提交要从字段中清除的联系表格时?

问题描述 投票:-1回答:4

我很好地提交了联系表格。一切都很好,但当我提交时,我想清除所有字段详细信息。输入没有刷新。

我的JavaScript

 $(document).ready(function(){
    $('#buttonme').click(function(){
        $.post("send.php", $("#myform").serialize(),  function(response) {   
            $('#contactstatus').html(response);
                //$('#success').hide('slow');
            });
        return false;
    });
});

我该如何刷新我必须在myscript中添加的内容

jquery contact-form
4个回答
0
投票

尝试这样:

$('#myform').each(function(){
    this.reset();
});

0
投票

这应该完成工作:

$('input')
.val('')
.removeAttr('checked')
.removeAttr('selected');

0
投票

您可以尝试以下方法:

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

http://jsfiddle.net/yj4S5/1/


0
投票

HTML

<form>
    <input type="text" />
    <input type="reset" id="reset" />
    <input type="button" id="buttonme" value="Submit"/>
</form>

js

$(document).ready(function () {
    $("input:reset").hide();
    $('#buttonme').click(function () {
        $("input:reset").click();
    });
});

正在运行的演示http://jsfiddle.net/cse_tushar/8URw4/

根据您的情况在您的屏幕上添加HTML

<input type="reset" id="reset" />

js

$(document).ready(function(){
    $('#buttonme').click(function(){
        $.post("send.php", $("#myform").serialize(),  function(response) {   
            $('#contactstatus').html(response);
                //$('#success').hide('slow');
            $("input:reset").click();//add this to your code
            });
        return false;
    });
});

或者您可以简单地使用

js

 $('form').trigger('reset');
© www.soinside.com 2019 - 2024. All rights reserved.