user4221466
user4221466

Reputation:

How to clear specific input field in jquery

I have a form. After getting a specific string from a jQuery Ajax request, I want to clear some input fields of a form by jQuery id selector. What should I do ?

My jQuery code:

    $.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);

    });

});

Upvotes: 1

Views: 1010

Answers (1)

Bhushan Kawadkar
Bhushan Kawadkar

Reputation: 28513

You can use below code to clear input field -

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

I have used id selector, you can use class or any other selector for selecting input (as per your requirement) and set empty string in .val('') to clear its value.

Upvotes: 2

Related Questions