如何使用 jQuery 清空输入字段 [英] How to empty input field with jQuery

查看:23
本文介绍了如何使用 jQuery 清空输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个移动应用程序中,我使用一个输入字段来让用户提交一个数字.

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>");
});

推荐答案

您可以使用 $('#shares').val('');

这篇关于如何使用 jQuery 清空输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆