jquery how to empty input field

kosbou picture kosbou · Feb 11, 2012 · Viewed 367.7k times · Source

I am in a mobile app and I use an input field in order user submit a number.

When I go back and return to the page that input field present the latest number input displayed at the input field.

Is there any way to clear the field every time the page load?

$('#shares').keyup(function(){
    payment = 0;
    calcTotal();
    gtotal = ($('#shares').val() * 1) + payment;
    gtotal = gtotal.toFixed(2);
    $("p.total").html("Total Payment: <strong>" + gtotal + "</strong>");
});

Answer

shaunsantacruz picture shaunsantacruz · Feb 11, 2012

You can clear the input field by using $('#shares').val('');