如何清除jquery中的特定输入字段

时间:2014-11-17 05:20:47

标签: javascript jquery

我有一张表格。从jQuery Ajax请求获取特定字符串后,我想通过jQuery id选择器清除表单的一些输入字段。我该怎么办?

我的jQuery代码:

    $.post(site_url.concat('xml_request/cert.php') , { special_code:special_code , cert_id_name:cert_id_name , recive_date:sector_dob5 , about_cert:about_cert } , function(data){


    $('#add_cert_feedback').html(data);

    if (data.indexOf('New Certificate is now Added') !== -1) {

        //Want to reset a Input field here

    } else {

        $('#the_heck').html('shit!');           
    }

    $.post(site_url.concat('xml_request/cert.php') , { special_code:'_get_array_cert' } , function(data){

        $('#cert_load').html(data);

    });

});

1 个答案:

答案 0 :(得分:2)

您可以使用以下代码清除输入字段 -

$('#inputId').val('');

我使用了id选择器,您可以使用class或任何其他选择器来选择input(根据您的要求)并在.val('')中设置空字符串以清除它的价值。

相关问题