jQuery如何清空输入字段 [英] jquery how to empty input field

查看:100
本文介绍了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天全站免登陆